Example #1
0
        /// <summary>
        /// Executes java script on a page/ Form. Pass the control names enclosed in $${ControlName}&&. ControlName is the key available from sitemaps.
        /// e.g.: If the JavaScript is "UsernameTextBox.Val('admin'), pass the script as "$$UserName$$.val('admin').
        /// If multiple controls needs to be used enclose each control in $${ControlName}&&.
        /// <param name="script">Java script to be executed.</param>
        public void ExecuteScript(string script)
        {
            FindType sourceType = FindType.ById;
            string   locator    = string.Empty;

            foreach (var item in Regex.Matches(script, "~[^~]+~"))
            {
                locator = _siteMapData.GetLocator(item.ToString().Trim('~', '~'), out sourceType);
                script  = script.Replace(item.ToString(), locator);
            }

            _client.ExecuteScript(script);
        }