Saturday 23 June 2012

Page load timeout is implemented in Selenium/WebDriver

Finally, page load time out is implemented in WebDriver, So IE9 hang issue with pages having multiple frames will not be a concern.:) It works with get and click method.
      We can set the page loadtime in webdriver.Suppose if we want facebook to be loaded within 60 sec then add below statement in your code


driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
driver.get("http://facebook.com/");

WebElement myElem = findElement("Your code to Find Element");
try{
myElem.click()
}catch(Exception e){
sysout("Eating the Exception");
}

If facebook failed to load within 60sec then script will fail.

If you do not want script to fail in the above condition, put the code in try catch block and eat the exception. 

Make sure you know the timing of your page load or after page load wait for the elements to appear. It may make your test scripts flaky.

Thanks!!

No comments:

Post a Comment

Related Posts

Related Posts...