Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

How to handle Page load timeout is implemented in Selenium/WebDriver ?




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

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

WebElement myElem = findElement("prop");
try{
myElem.click()
}catch(Exception e){
sysout("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.

Post a Comment

0 Comments