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

New Methods in WebDriver ExpectedConditions Class

Irrespective of the business that your client is in, marketing is an integral part of their operations. In fact, in this day and age of social.

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"));
  

Written By

Submit a Comment

Your email address will not be published. Required fields are marked *


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"));