本文整理汇总了C#中IWebDriver.WaitForElement方法的典型用法代码示例。如果您正苦于以下问题:C# IWebDriver.WaitForElement方法的具体用法?C# IWebDriver.WaitForElement怎么用?C# IWebDriver.WaitForElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWebDriver
的用法示例。
在下文中一共展示了IWebDriver.WaitForElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpecifyForBrowser
public override void SpecifyForBrowser(IWebDriver browser)
{
var server = beforeAll(() => new StaticServer()
{
{"jquery.js", JQuerySource.GetJQuerySource()}
}.Start());
beforeAll(() => server.Add("delay.html",
JQueryUtil.HtmlLoadingJQuery(server.UrlFor("jquery.js"), "<div> Hello, world. </div>")));
describe("WaitForElement", delegate
{
arrange(() => browser.Navigate().GoToUrl(server.UrlFor("delay.html")));
it("can find an element on the page", delegate
{
expect(() => browser.WaitForElement(BySizzle.CssSelector("div:contains('Hello, world')")) != null);
});
it("reports a useful error if the element is not eventually found", delegate
{
var expectedMessage = Assert.Throws<NoSuchElementException>(delegate
{
browser.FindElement(By.CssSelector("div div li ul ol lol.so img.nothappening"));
}).Message;
var actualException = Assert.Throws<NoSuchElementException>(delegate
{
browser.WaitForElement(By.CssSelector("div div li ul ol lol.so img.nothappening"));
});
expect(() => actualException.Message.Contains(expectedMessage));
});
it("will wait for elements", delegate
{
(browser as IJavaScriptExecutor).ExecuteScript(@"
setTimeout(function() { $('body').append('<div>Better late than never.</div>'); }, 2000);
");
expect(() => browser.WaitForElement(BySizzle.CssSelector("div:contains('Better late than never.')")) != null);
});
});
}
开发者ID:fschwiet,项目名称:SizSelCsZzz,代码行数:44,代码来源:WaitForElement_waits_until_Selenium_finds_an_element.cs
示例2: InputIsEmptyOrNotExampleText
private bool InputIsEmptyOrNotExampleText(IWebDriver webDriver)
{
IWebElement foundElement = null;
try
{
foundElement = webDriver.WaitForElement(_pageElement.By, timeout: new TimeSpan(0, 0, 1));
}
catch (WebDriverTimeoutException)
{
}
if (foundElement == null)
return false;
string valueAttribute = foundElement.GetAttribute("value");
string dbtAttribute = foundElement.GetAttribute("dbt");
if (valueAttribute == null || dbtAttribute == null)
return false;
return valueAttribute.Equals(String.Empty) || !valueAttribute.Equals(dbtAttribute);
}
示例3: should_have_registration_fields
private void should_have_registration_fields(IWebDriver browser, params string[] options)
{
browser.WaitForElement(GetRegistrationInputSelector());
var allTheTextFields = browser.FindElements(GetRegistrationInputSelector()).Select(e => e.GetAttribute("name")).ToArray();
Assert.That(allTheTextFields, Is.EquivalentTo(options));
}