Web Driver Wait



1) WebDriverWait wait = new WebDriverWait(driver, waitTime);
   wait.until(ExpectedConditions.presenceOfElementLocated(locator));
  The above statement will check for the element presence on the DOM of a page.
  This does not necessarily mean that the element is visible.

2)WebDriverWait wait = new WebDriverWait(driver, waitTime);
wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
The above syntax will for the element present in the DOM of a page is visible.

3) WebDriverWait wait = new WebDriverWait(driver, waitTime); wait.until(ExpectedConditions.invisibilityOfElementLocated(locator));

Some times we may also need to check if the element is invisible or not. To do this we need use the above
4)  WebDriverWait wait = new WebDriverWait(driver, waitTime); wait.until(ExpectedConditions.elementToBeClickable(locator));


Sometimes you will get an exception as ""org.openqa.selenium.WebDriverException: Element is not clickable at point (611, 419). Other element would receive the click:'. The above one is used to wait for the element to be clickable.

Comments