Sunday 21 October 2012

Avoid explicit delay in selenium


If you are using java with selenium for automation,then you should use explicit delay in your code(like Thread.sleep(2000)).

Here is an example for same:

WebDriverWait wait = new WebDriverWait(webDriver, 5);//here 5 is a maximum waiting time in seconds
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@value='SignIn']")));

//ExpectedConditions have lot of functions for different actions,so use these functions according your requirement.

No comments:

Post a Comment