Esempio n. 1
0
        // Help method to wait for first option available
        public void WaitForFirstOptionAvailable()
        {
            var myWait        = new WebDriverWait(SeleniumWebDriver, TimeSpan.FromSeconds(Timeout));
            var id            = SeleniumWebDriver.FindElement(Identifier).GetAttribute("id");
            var childSelector = "#" + id + " > option:nth-child(2)";

            myWait.Until(d => d.FindElement(By.CssSelector(childSelector)));
        }
Esempio n. 2
0
        private bool IsElementExists(SeleniumWebDriver selenium, string locator, FindType type)
        {
            if (string.IsNullOrWhiteSpace(locator))
            {
                return(false);
            }

            try
            {
                IWebElement element = selenium.FindElement(locator, type, retry: false);

                if (null == element)
                {
                    return(false);
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 3
0
        // Retrieve value of selected text
        public string GetSelectedOptionText()
        {
            var selectElement = new SelectElement(SeleniumWebDriver.FindElement(Identifier));

            return(selectElement.SelectedOption.Text);
        }
Esempio n. 4
0
        // Select option by option's position
        public void SelectByIndex(int index)
        {
            var selectElement = new SelectElement(SeleniumWebDriver.FindElement(Identifier));

            selectElement.SelectByIndex(index);
        }
Esempio n. 5
0
        // Select option by option's text
        public void SelectByText(string text)
        {
            var selectElement = new SelectElement(SeleniumWebDriver.FindElement(Identifier));

            selectElement.SelectByText(text);
        }
 // Click the button
 public void Click()
 {
     SeleniumWebDriver.FindElement(Identifier).Click();
 }
Esempio n. 7
0
 // Help method to get text of element on the page
 public string GetText()
 {
     return(SeleniumWebDriver.FindElement(Identifier).Text);
 }