How can i use waitForCondition() function using FirefoxDriver Object?
I am new to Selenium testing. I am using FireFoxDriver for developing automated testcases. Do we have any option of using waitForCondition() method using FireFoxDriver Object? My application is based on ajax and i need to select the dropdown list that is generated by AJAX.
开发者_开发百科Please HELP
By http://seleniumhq.org/docs/03_webdriver.html
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
});
You can manually implement it, something like:
bool condition = false;
while (!condition)
{
try
{
condition = ...
}
catch (Exception)
{
}
Thread.sleep(500);
}
the try-catch block lets you use FindElement to search of a specific element (in this case your dropdown list).
Alternatively you can set the timeout time like so:
FirefoxDriver driver = new FirefoxDriver();
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
Any call will automatically keep trying to find the necessary elements for the amount of time you specified before throwing an exception
精彩评论