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/");
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.
0 Comments