Ejemplo n.º 1
0
        public static void ClickRadioButton(this IWebElement radioButton)
        {
            if (radioButton == null)
                throw new ArgumentNullException("radioButton");

            var elementId = radioButton.GetId();
            var jQuery = string.Format("return $('#{0}').is(':checked');", elementId);
            while (!(bool)radioButton.Browser().ExecuteScript(jQuery))
            {
                radioButton.ClickRadioOrCheckBox();
            }
        }
Ejemplo n.º 2
0
        public static void CheckOrUncheckCheckBox(this IWebElement checkBox, bool shouldCheck)
        {
            if (checkBox == null)
                throw new ArgumentNullException("checkBox");

            // get the id of the checkbox & browser
            var browser = checkBox.Browser();
            var elementId = checkBox.GetId();

            // make sure checkbox is visible
            browser.WaitUntil(b => checkBox.Displayed, string.Format(
                "The check box with id '{0}' was not displayed using @Browser.", elementId));

            // generate script to find out whether or not the checkbox is checked
            var jQuery = string.Format("return $('#{0}').is(':checked')", elementId);

            // find out whether the box is checked or not
            var isChecked = (bool)browser.ExecuteScript(jQuery);
            if (shouldCheck == isChecked) return; // if the box is in the expected state, this step is over
            while (shouldCheck != (bool)browser.ExecuteScript(jQuery))
            {
                checkBox.ClickRadioOrCheckBox();
            }
        }