本文整理汇总了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;
}
示例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;
}
示例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;
});
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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));
}
示例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']")));
}
示例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);
}
}
示例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;
}
示例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;
});
}
示例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()));
}
示例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;
}