开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜