示例#1
0
        public static string GetSelectedOptionTextWhenVisible(this IWebDriver driver, By locator)
        {
            string WebDriverActions()
            {
                driver.Wait().Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(locator));
                return(new SelectElement(driver.FindElement(locator)).SelectedOption.Text);
            }

            return(FunctionRetrier.RetryOnException <string, StaleElementReferenceException>(WebDriverActions));
        }
示例#2
0
        public static string GetElementAttributeValueWhenVisible(this IWebDriver driver, By locator, string attribute)
        {
            string WebDriverActions()
            {
                driver.Wait().Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(locator));
                return(driver.FindElement(locator).GetAttribute(attribute));
            }

            return(FunctionRetrier.RetryOnException <string, StaleElementReferenceException>(WebDriverActions));
        }
示例#3
0
        public static string[] GetMultipleElementTextValuesWhenVisible(this IWebDriver driver, By locator)
        {
            string[] WebDriverActions()
            {
                driver.Wait().Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(locator));
                return(driver.FindElements(locator).Select(e => e.Text).ToArray());
            }

            return(FunctionRetrier.RetryOnException <string[], StaleElementReferenceException>(WebDriverActions));
        }
示例#4
0
        public static void SendKeysWhenVisible(this IWebDriver driver, By locator, string value)
        {
            void WebDriverActions()
            {
                IWebElement element = driver.Wait().Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(locator));

                element.Clear();
                element.SendKeys(value);
            }

            FunctionRetrier.RetryOnException <StaleElementReferenceException>(WebDriverActions);
        }
示例#5
0
        public static void ClickElementWhenClickable(this IWebDriver driver, By locator)
        {
            void WebDriverActions()
            {
                IWebElement elementToClick = driver.Wait().Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(locator));

                new Actions(driver)
                .MoveToElement(elementToClick)
                .Click()
                .Perform();
            }

            FunctionRetrier.RetryOnException <StaleElementReferenceException>(WebDriverActions);
        }