Tuesday, 7 August 2018

SE - 33 - Can we use multiple conditions when we apply Explicit wait

We can apply multiple conditions while implementing explicit wait in webdriver. We can give multiple conditions by using OR\AND with ExpectedConditions class. Example below :


public class MultipleWaits {

 public void mulwwait() {
  WebDriver driver = new ChromeDriver();
  
  WebDriverWait Wait = new WebDriverWait(driver , 10);
  Wait.until(ExpectedConditions.and(          //here AND\OR conditions can be applied here
    ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("Path1")),
    ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("Path1")),
    ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("Path1"))
    )
    );
 }
}
In the above example I have used AND conditions for giving multiple conditions to webdriver explicit wait. We can also use OR in place of it.

No comments:

Post a Comment