New Methods in WebDriver ExpectedConditions Class - Codoid
Select Page
Codoid Blog

New Methods in WebDriver ExpectedConditions Class

Being a leading QA Company, we write blogs on all prominent software testing topics and tools using our real-world experience. So stay sharp by subscribing to our Newsletter.

In Selenium WebDriver 2.53.0 release, we have new methods addition in ExpectedConditions class. All are really helpful for extensive validations and adding synchronization points in test scripts.

Attribute Validation

wait.until(ExpectedConditions.attributeContains(By.cssSelector("box"),"name","txt"));
wait.until(ExpectedConditions.attributeToBe(By.cssSelector("box"),"name","txt1"));
wait.until(ExpectedConditions.attributeToBeNotEmpty(element,"name"));
  

Waiting for Elements Count

wait.until(ExpectedConditions.numberOfElementsToBe(By.cssSelector("box"),5));
wait.until(ExpectedConditions.numberOfElementsToBeLessThan(By.cssSelector("box"),5));
wait.until(ExpectedConditions.numberOfElementsToBeMoreThan(By.cssSelector("box"),5));
  

Waiting for a text in an element

wait.until(ExpectedConditions.textMatches(By.cssSelector("box"),Pattern.compile("(.*)(\\d+)(.*)")));
wait.until(ExpectedConditions.textToBe(By.cssSelector("box"),"Sample"));
  

Submit a Comment

Your email address will not be published.


In Selenium WebDriver 2.53.0 release, we have new methods addition in ExpectedConditions class. All are really helpful for extensive validations and adding synchronization points in test scripts.

Attribute Validation

wait.until(ExpectedConditions.attributeContains(By.cssSelector("box"),"name","txt"));
wait.until(ExpectedConditions.attributeToBe(By.cssSelector("box"),"name","txt1"));
wait.until(ExpectedConditions.attributeToBeNotEmpty(element,"name"));
  

Waiting for Elements Count

wait.until(ExpectedConditions.numberOfElementsToBe(By.cssSelector("box"),5));
wait.until(ExpectedConditions.numberOfElementsToBeLessThan(By.cssSelector("box"),5));
wait.until(ExpectedConditions.numberOfElementsToBeMoreThan(By.cssSelector("box"),5));
  

Waiting for a text in an element

wait.until(ExpectedConditions.textMatches(By.cssSelector("box"),Pattern.compile("(.*)(\\d+)(.*)")));
wait.until(ExpectedConditions.textToBe(By.cssSelector("box"),"Sample"));