Showing posts with label Implicit wait and Explicitly wait. Show all posts
Showing posts with label Implicit wait and Explicitly wait. Show all posts

Friday, May 9, 2014

Sychronizing the WebDriver (Implicit wait and Explicitly wait)

Implicit wait-


Syntax- driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
Here it will wait for 10sec if while execution driver did not find the element in the page immediately. This code will attach with each and every line of the script automatically. It is not required to write everytime. Just write it once after opening the browser. If element found before assigned value, it will continue with the script, it will not wait for completely 10sec.

Explicit wait-
Syntax- Thread.sleep or use WebDriverWait wait = new WebDriverWait(driver, 10);//here 10 is 10sec
ex- wait.until(ExpectedConditions.elementToBeClickable(By.id("login")));
In this case wherever we want to wait we have to write the explicit wait command and it will wait for that particular time whether element found or not.