Пример #1
0
        public void SelectValue(string value)
        {
            WaitForElementPresent();
            var select = new UISelectElement(GetElement());

            select.SelectByText(value);
        }
Пример #2
0
        /// <summary>
        /// Select from a dropdown by text
        /// </summary>
        /// <param name="element">Select element</param>
        /// <param name="text">Option text</param>
        public static void SelectByText(this IBrowser browser, SelectElement element, string text)
        {
            // Create selenium select element object
            var select = new OpenQA.Selenium.Support.UI.SelectElement(browser.Find(element));

            // Select by value
            select.SelectByText(text);
        }
Пример #3
0
        public virtual TResult SelectedText <TResult>(string text) where TResult : IBlock
        {
            var select =
                new OpenQA.Selenium.Support.UI.SelectElement(Tag);

            select.SelectByText(text);
            return(Session.CurrentBlock <TResult>(ParentBlock.Tag));
        }
Пример #4
0
        public void SetValue(string value, SelectMode selectMode)
        {
            if (selectMode == SelectMode.Value)
            {
                try
                {
                    _element.SelectByValue(value);
                }
                catch (NoSuchElementException)
                {
                    try
                    {
                        _element.SelectByText(value);
                    }
                    catch (NoSuchElementException)
                    {
                    }
                }
            }
            else if (selectMode == SelectMode.Text)
            {
                try
                {
                    _element.SelectByText(value);
                }
                catch (NoSuchElementException)
                {
                    throw new NoSuchElementException("Cannot locate option with text: " + value);
                }
            }
            else if (selectMode == SelectMode.Index)
            {
                try
                {
                    _element.SelectByIndex(Int32.Parse(value));
                }
                catch (NoSuchElementException)
                {
                    throw new NoSuchElementException("Cannot location option at index: " + value);
                }
            }

            this.OnChange();
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="drdXpath"></param>
        /// <param name="searchValue">Unique full text of the option to search</param>
        public static void SelectValueFromDropdown(string drdXpath, string searchValue)
        {
            // select the drop down list
            var education = driver.FindElement(By.XPath(drdXpath));
            //create select element object
            var selectElement = new OpenQA.Selenium.Support.UI.SelectElement(education);

            // select by text
            selectElement.SelectByText(searchValue);
        }
Пример #6
0
        public void PopulateMenu(string burgerType, string firstName)
        {
            this.additionalSugarCheckbox.Click();
            additionalSugarCheckbox.Click();
            var burgersSelect = new OpenQA.Selenium.Support.UI.SelectElement(burgersSelectElement);

            burgersSelect.SelectByText(burgerType);
            firstNameTextInput.Clear();
            firstNameTextInput.SendKeys(firstName);
        }
Пример #7
0
        public void incluirPergunta(string descricao)
        {
            selecionarMenuPergunta();



            driver.FindElement(By.Id("btnIncluir")).Click();
            driver.FindElement(By.Id("inputDescrTipoPergunta")).SendKeys(descricao);

            var combobox      = driver.FindElement(By.Id("dropStatus"));
            var selectElement = new OpenQA.Selenium.Support.UI.SelectElement(combobox);

            selectElement.SelectByText("Ativo");

            driver.FindElement(By.Id("btnSalvar")).Click();
            Thread.Sleep(1000);
        }
Пример #8
0
        public void Logar(string usuario, string senha)
        {
            driver.FindElement(By.Id("txtLogin")).SendKeys(usuario);
            driver.FindElement(By.Id("txtSenha")).SendKeys(senha);
            driver.FindElement(By.Id("btnEnviar")).Click();


            var comboboxSistema      = driver.FindElement(By.Id("cmbSistemas"));
            var selectElementSistema = new OpenQA.Selenium.Support.UI.SelectElement(comboboxSistema);

            selectElementSistema.SelectByText("SISTEMA ELETRÔNICO DA OUVIDORIA");

            Thread.Sleep(1000);

            var comboboxOrgao      = driver.FindElement(By.Id("cmbOrgaos"));
            var selectElementOrgao = new OpenQA.Selenium.Support.UI.SelectElement(comboboxOrgao);

            selectElementOrgao.SelectByText("OUVID OUVIDORIA GERAL DO PODER JUDICIARIO");
        }
Пример #9
0
        public bool selectByVisibleText(By locator, string visibletext, string locatorName)
        {
            bool flag = false;

            try
            {
                /*Highlight element*/

                WebElement         webElement = driver.FindElement(locator);
                JavascriptExecutor js         = driver as JavascriptExecutor;
                js.ExecuteScript("arguments[0].style.border='4px solid yellow'", webElement);
                /*Highlight code ends*/
                Select s = new Select(driver.FindElement(locator));
                s.SelectByText(visibletext);
                flag = true;
                return(flag);
            }
            catch (Exception)
            {
                return(flag);
            }
        }
Пример #10
0
        public void SetValues(Expression <Func <string, bool> > optionMatchingExpression, SelectMode selectMode)
        {
            var compiledFunc = optionMatchingExpression.Compile();

            if (selectMode == SelectMode.Value)
            {
                var options = _element.Options.Where(x => compiledFunc(x.GetAttribute("value"))).Select <IWebElement, string>(x => x.GetAttribute("value")).ToList();
                foreach (var optionValue in options)
                {
                    // dirty hack is dirty!
                    OpenQA.Selenium.Support.UI.SelectElement element = new OpenQA.Selenium.Support.UI.SelectElement(this.GetWebElement(true));
                    element.SelectByValue(optionValue);
                }

                if (options.Count() == 0)
                {
                    throw new SelectException("Selection failed. No option values matched expression [{0}] on element.", optionMatchingExpression.ToExpressionString());
                }
            }
            else if (selectMode == SelectMode.Text)
            {
                var options = _element.Options.Where(x => compiledFunc(x.Text)).Select <IWebElement, string>(x => x.Text).ToList();
                foreach (var optionText in options)
                {
                    // dirty hack is dirty!
                    OpenQA.Selenium.Support.UI.SelectElement element = new OpenQA.Selenium.Support.UI.SelectElement(this.GetWebElement(true));
                    element.SelectByText(optionText);
                }

                if (options.Count() == 0)
                {
                    throw new SelectException("Selection failed. No option text matched expression [{0}] on element.", optionMatchingExpression.ToExpressionString());
                }
            }

            this.OnChange();
        }
Пример #11
0
 protected void ComboBoxSelectByVisibleText(By locator, string text)
 {
     OpenQA.Selenium.Support.UI.SelectElement comboBox = new OpenQA.Selenium.Support.UI.SelectElement(WaitForElement(locator));
     comboBox.SelectByText(text);
     ExtentReportHelpers.AddTestInfo(3, "PARAMETER: " + text);
 }
Пример #12
0
 public void SelectValue(string value)
 {
     WaitUntilDisplayed();
     _select.SelectByText(value);
 }
Пример #13
0
        public void ChromeTest()
        {
            using (var WebDriver = new ChromeDriver())
            {
                WebDriver.Manage().Window.Maximize();
                WebDriver.Navigate().GoToUrl(baseURL);

                var firstName = WebDriver.FindElementById("RESULT_TextField-2");
                firstName.SendKeys("Marco");

                var lastName = WebDriver.FindElementById("RESULT_TextField-3");
                lastName.SendKeys("Serrano");

                var address = WebDriver.FindElementById("RESULT_TextField-4");
                address.SendKeys("123 Street St.");

                var address2 = WebDriver.FindElementById("RESULT_TextField-5");
                address2.SendKeys("Apt 123");

                var city = WebDriver.FindElementById("RESULT_TextField-6");
                city.SendKeys("Townsville");

                var state         = WebDriver.FindElementById("RESULT_RadioButton-7");
                var selectElement = new OpenQA.Selenium.Support.UI.SelectElement(state);
                selectElement.SelectByText("Texas");

                var zipCode = WebDriver.FindElementById("RESULT_TextField-8");
                zipCode.SendKeys("77777");

                var phone = WebDriver.FindElementById("RESULT_TextField-9");
                phone.SendKeys("5557771234");

                var email = WebDriver.FindElementById("RESULT_TextField-10");
                email.SendKeys("*****@*****.**");

                OpenQA.Selenium.Interactions.Actions actions = new Actions(WebDriver);
                actions.MoveToElement(email);
                actions.Perform();

                var membership = WebDriver.FindElementByXPath("//div[@id='q16']/table/tbody/tr/td/label");
                membership.Click();
                membership = WebDriver.FindElementByXPath("//div[@id='q16']/table/tbody/tr/td[1]/label");
                membership.Click();
                membership = WebDriver.FindElementByXPath("//div[@id='q16']/table/tbody/tr/td[2]/label");
                membership.Click();

                var contact = WebDriver.FindElementByXPath("//div[@id='q21']/table/tbody/tr/td/label");
                contact.Click();
                contact = WebDriver.FindElementByXPath("//div[@id='q21']/table/tbody/tr/td[2]/label");
                contact.Click();
                contact = WebDriver.FindElementByXPath("//div[@id='q21']/table/tbody/tr/td[3]/label");            //contact.Click();
                contact.Click();

                var terms = WebDriver.FindElementByXPath("//div[@id='q30']/table/tbody/tr/td/label");
                terms.Click();

                var submit = WebDriver.FindElementById("FSsubmit");
                submit.Submit();

                Thread.Sleep(5000);

                WebDriver.Close();
            }
        }
Пример #14
0
        public void SetValues(Expression<Func<string, bool>> optionMatchingExpression, SelectMode selectMode)
        {
            var compiledFunc = optionMatchingExpression.Compile();
            if (selectMode == SelectMode.Value)
            {
                var options = _element.Options.Where(x => compiledFunc(x.GetAttribute("value"))).Select<IWebElement, string>(x => x.GetAttribute("value")).ToList();
                foreach (var optionValue in options)
                {
                    // dirty hack is dirty!
                    OpenQA.Selenium.Support.UI.SelectElement element = new OpenQA.Selenium.Support.UI.SelectElement(this.GetWebElement(true));
                    element.SelectByValue(optionValue);
                }

                if (options.Count() == 0)
                {
                    throw new SelectException("Selection failed. No option values matched expression [{0}] on element.", optionMatchingExpression.ToExpressionString());
                }
            }
            else if (selectMode == SelectMode.Text)
            {
                var options = _element.Options.Where(x => compiledFunc(x.Text)).Select<IWebElement, string>(x => x.Text).ToList();
                foreach (var optionText in options)
                {
                    // dirty hack is dirty!
                    OpenQA.Selenium.Support.UI.SelectElement element = new OpenQA.Selenium.Support.UI.SelectElement(this.GetWebElement(true));
                    element.SelectByText(optionText);
                }

                if (options.Count() == 0)
                {
                    throw new SelectException("Selection failed. No option text matched expression [{0}] on element.", optionMatchingExpression.ToExpressionString());
                }
            }

            this.OnChange();
        }