当前位置: 首页>>代码示例>>C#>>正文


C# WebDriverWait.IgnoreExceptionTypes方法代码示例

本文整理汇总了C#中WebDriverWait.IgnoreExceptionTypes方法的典型用法代码示例。如果您正苦于以下问题:C# WebDriverWait.IgnoreExceptionTypes方法的具体用法?C# WebDriverWait.IgnoreExceptionTypes怎么用?C# WebDriverWait.IgnoreExceptionTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebDriverWait的用法示例。


在下文中一共展示了WebDriverWait.IgnoreExceptionTypes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WaitUntilZero

 public SeleniumSteps WaitUntilZero()
 {
   var wait = new WebDriverWait(_driver, new TimeSpan(1, 0, 0));
   wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
   wait.IgnoreExceptionTypes(typeof(StaleElementReferenceException));
   wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("buyingtools-add-to-cart-button")));
   return this;
 }
开发者ID:ztmdsbt-studio,项目名称:Purchase,代码行数:8,代码来源:SeleniumSteps.cs

示例2: GetElementFromActivePage

        // This should be replaced for any given application; this isn't a one-size-fits-all sort of thing.
        public static IWebElement GetElementFromActivePage(this IWebDriver driver, string cssSelector, double timeoutSeconds = 20)
        {
            IWebElement element = null;
            var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutSeconds));
            wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(WebDriverTimeoutException),typeof(UnhandledAlertException));
            try
            {
                element = wait.Until(drv =>
                {
                    try
                    {
                        return drv.FindElement(By.CssSelector(cssPrefix + cssSelector));
                    }
                    catch (NoSuchElementException ex)
                    {
                        return null;
                    }
                });
            }
            catch (WebDriverTimeoutException ex)
            {
                return null;
            }

            return element;
        }
开发者ID:jw56578,项目名称:SpecFlowTest,代码行数:27,代码来源:WebDriverExtensions.cs

示例3: CheckConstituentSearchResultsContain

        /// <summary>
        /// Checks that the search results contain the specified string on a SearchDialog.
        /// Throws an exception on failure.
        /// 
        /// </summary>
        /// <param name="expected">The string to check for.</param>
        public static void CheckConstituentSearchResultsContain(string expected)
        {
            var waiter = new WebDriverWait(Driver, TimeSpan.FromSeconds(TimeoutSecs));
            waiter.IgnoreExceptionTypes(typeof(InvalidOperationException));
            ICollection<IWebElement> nameFieldElements = new Collection<IWebElement>();
            waiter.Until(d =>
                {
                    var constituentSearchResultsToolbarElement = Driver.FindElement(By.XPath(getXResultsBar));
                    nameFieldElements = Driver.FindElements(By.XPath(getXGridNameField));
                    var constituentSearchResultsGrid = Driver.FindElement(By.XPath(getXSearchResultsGrid));

                    if ((nameFieldElements == null ||
                         !constituentSearchResultsGrid.Displayed ||
                         !constituentSearchResultsToolbarElement.Text.Contains("found"))) return false;

                    var names = from element in nameFieldElements select element.Text;

                    if (!names.Contains(expected)) return false;
                    //{
                    //    throw new Exception(String.Format("CheckConstituentResultsContain Failed: Expected Name '{0}' was not found in the Results.", expected));
                    //}

                    return true;
                });
        }
开发者ID:Blackbaud-LucasWestervelt,项目名称:uat-kit,代码行数:31,代码来源:SearchDialog.cs

示例4: GetWebDriverWait

        public static WebDriverWait GetWebDriverWait(int timeOutInSeconds)
        {
            var wait = new WebDriverWait(ObjectRepository.Driver, TimeSpan.FromSeconds(timeOutInSeconds));
            wait.PollingInterval = TimeSpan.FromMilliseconds(250);
            wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException));
            return wait;

        }
开发者ID:rohanbaraskar,项目名称:SummerOutreachWebdriver,代码行数:8,代码来源:GenericHelper.cs

示例5: WaitUntilAvailable

 public static void WaitUntilAvailable(Func<IWebDriver, object> condition)
 {
     IWait<IWebDriver> wait = new WebDriverWait(Driver,
         TimeSpan.FromSeconds(30));
     wait.Timeout = TimeSpan.FromSeconds(60);
     wait.PollingInterval = TimeSpan.FromSeconds(1);
     wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
     wait.Until(condition);
 }
开发者ID:AlexNaryzhny,项目名称:helloci,代码行数:9,代码来源:BasePage.cs

示例6: GetWebdriverWait

 public static WebDriverWait GetWebdriverWait(TimeSpan timeout)
 {
     ObjectRepository.Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
     WebDriverWait wait = new WebDriverWait(ObjectRepository.Driver, timeout)
     {
         PollingInterval = TimeSpan.FromMilliseconds(500),
     };
     wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException));
     return wait;
 }
开发者ID:Saltorel,项目名称:BDD-CSharp,代码行数:10,代码来源:GenericHelper.cs

示例7: FindElement

 public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds)
 {
     if (timeoutInSeconds > 0)
     {
         var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));
         wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
         return wait.Until(drv => drv.FindElement(by));
     }
     return driver.FindElement(by);
 }
开发者ID:rohanbaraskar,项目名称:CSharpSelenium,代码行数:10,代码来源:WebDriverExtensions.cs

示例8: SelectIssueType

        public void SelectIssueType(string issueType)
        {
            var issueField = BaseElement.FindElement(By.Id("issuetype-field"));
            issueField.SendKeys(issueType+Keys.Enter);

            var wait = new WebDriverWait(_Af.Driver, TimeSpan.FromSeconds(AutomationFramework.Timeout));
            wait.IgnoreExceptionTypes(typeof(StaleElementReferenceException));
            wait.Until(_ => BaseElement.FindElement(By.XPath(WidgetLoadXPath))
                                       .GetAttribute("class") != LoadingClass);
        }
开发者ID:gkalnytskyi,项目名称:JiraAutomation,代码行数:10,代码来源:CreateIssueWidget.cs

示例9: UntilVisible

        public static IWebElement UntilVisible(By by, IWebDriver driver, TimeSpan timeOut)
        {
            WebDriverWait wdWait = new WebDriverWait(driver, timeOut);
            wdWait.IgnoreExceptionTypes
            (
                typeof(ElementNotVisibleException),
                typeof(NoSuchElementException),
                typeof(StaleElementReferenceException)
            );

            return wdWait.Until(ExpectedConditions.ElementIsVisible(by));
        }
开发者ID:Kreisfahrer,项目名称:SWD.Starter,代码行数:12,代码来源:Wait.cs

示例10: TestExpCondition

 public void TestExpCondition()
 {
     NavigationHelper.NavigateToUrl("https://www.udemy.com/");
     ObjectRepository.Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
     WebDriverWait wait = new WebDriverWait(ObjectRepository.Driver, TimeSpan.FromSeconds(50));
     wait.PollingInterval = TimeSpan.FromMilliseconds(250);
     wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException));
     wait.Until(ExpectedConditions.ElementExists(By.XPath("//input[@type='search']"))).SendKeys("HTML");
     ButtonHelper.ClickButton(By.CssSelector(".home-search-btn"));
     wait.Until(ExpectedConditions.ElementExists(By.XPath("//*[@id='courses']/li[12]/a/div[2]/div[1]/div/span"))).Click();
     Console.WriteLine("Title : {0}", wait.Until(ExpectedConditions.TitleContains("u")));
     wait.Until(ExpectedConditions.ElementExists(By.XPath("//a[contains(text(),'Login')]"))).Click();
     wait.Until(ExpectedConditions.ElementExists(By.XPath("//div[@class='loginbox-v4 js-signin-box']")));
 }
开发者ID:Saltorel,项目名称:BDD-CSharp,代码行数:14,代码来源:TestWebDeriverWait.cs

示例11: WaitFor

 public static IWebElement WaitFor(By by, TimeSpan timeout)
 {
     var timeouts = Driver.Manage().Timeouts();
     timeouts.ImplicitlyWait(TimeSpan.MinValue);
     try
     {
         IWait<IWebDriver> wait = new WebDriverWait(Driver, timeout);
         wait.IgnoreExceptionTypes(DefaultWaitForElementIgnoredExceptions);
         return wait.Until(drv => drv.FindElement(by));
     }
     finally
     {
         timeouts.ImplicitlyWait(DefaultImplicitlyWait);
     }
 }
开发者ID:bjozefczyk,项目名称:AutomationFramework,代码行数:15,代码来源:Browser.cs

示例12: WaitForElement

        public static bool WaitForElement(IWebDriver driver, TimeSpan timeout, By elementSelector)
        {
            try
            {
                var wait = new WebDriverWait(driver, timeout);
                wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
                wait.Until(x => x.FindElement(elementSelector));
            }
            catch
            {
                return false;
            }

            return true;
        }
开发者ID:MichalGrzegorzak,项目名称:Ylvis,代码行数:15,代码来源:WebElementExtensions.cs

示例13: WaitForAjaxElementVisible

        public static void WaitForAjaxElementVisible(this IWebDriver driver, By byElement, double timeoutSeconds)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutSeconds));
            wait.IgnoreExceptionTypes(typeof(StaleElementReferenceException));
            wait.Until(x => 
                {
                    IWebElement element = x.FindElement(byElement);
                    if (element != null)
                    {
                        return element.Displayed == true;
                    }

                    return false;
                });
        }
开发者ID:IanFelton,项目名称:WeNeedUHave,代码行数:15,代码来源:WebDriverExtensions.cs

示例14: TestDynamciWait

        public void TestDynamciWait()
        {
            NavigationHelper.NavigateToUrl("https://www.udemy.com/");
            ObjectRepository.Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
            WebDriverWait wait = new WebDriverWait(ObjectRepository.Driver, TimeSpan.FromSeconds(50));
            wait.PollingInterval = TimeSpan.FromMilliseconds(250);
            wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException));

            // Console.WriteLine(wait.Until(waitforTitle()));
            // IWebElement element = wait.Until(waitforElement());
            // element.SendKeys("java");
            wait.Until(this.WaitforElement()).SendKeys("health");
            ButtonHelper.ClickButton(By.CssSelector(".home-search-btn"));
            wait.Until(this.WaitforLastElemet()).Click();
            Console.WriteLine("Title : {0}", wait.Until(this.WaitforpageTitle()));
        }
开发者ID:Saltorel,项目名称:BDD-CSharp,代码行数:16,代码来源:TestWebDeriverWait.cs

示例15: GetWebDriverWait

        public static WebDriverWait GetWebDriverWait(int timeOutInSeconds)
        {
            if (_wait != null)
            {
                Logger.Info(" Wait Object Created ");
                return _wait;
            }

            _wait = new WebDriverWait(ObjectRepository.Driver, TimeSpan.FromSeconds(timeOutInSeconds))
            {
                PollingInterval = TimeSpan.FromMilliseconds(250),
            };

            _wait.IgnoreExceptionTypes(typeof(NoSuchElementException),typeof(ElementNotVisibleException));
            Logger.Info(" Wait Object Created ");
            return _wait;
        }
开发者ID:rahulrathore44,项目名称:ParkandCompanyCSharp,代码行数:17,代码来源:GenericHelper.cs


注:本文中的WebDriverWait.IgnoreExceptionTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。