コード例 #1
0
        public static void WaitForElement(this RemoteWebDriver driver, By by)
        {
            var attempts = WaitTimes;

            while (attempts > 0)
            {
                try
                {
                    ExecuteWithLogging(() => FluentWait.Create(driver)
                                       .WithTimeout(WaitTimeout)
                                       .WithPollingInterval(PollingInterval)
                                       .Until(WebDriverWaits.VisibilityOfAllElementsLocatedBy(by)), by);
                    return;
                }
                // System.InvalidOperationException : Error determining if element is displayed (UnexpectedJavaScriptError)
                catch (InvalidOperationException e)
                {
                    Console.WriteLine("Following Exception is occured in the WaitForElement method: {0}", e.Message);
                }
                // System.InvalidOperationException :The xpath expression './/option[contains(text(),'xxx')]' cannot be evaluated or does notresult in a WebElement
                catch (InvalidSelectorException e)
                {
                    Console.WriteLine("Following Exception is occured in the WaitForElement method: {0}", e.Message);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Error waiting element by '{by}' : {e.Message}");
                    throw;
                }
                finally
                {
                    attempts--;
                }
            }
        }
コード例 #2
0
        public static void WaitWhileControlIsNotDisplayed(this RemoteWebDriver driver, By by)
        {
            WebDriverWait wait = new WebDriverWait(driver, WaitTimeout);

            wait.Until(WebDriverWaits.VisibilityOfAllElementsLocatedBy(by));
        }