Although in some cases testers will try to use Selenium WebDriver wait methods to wait for certain conditions to be fulfilled before trying the interaction, they might still get test failures. So what would be a good solution to have reliable tests? 🤔 Read on to see how we can create aggregated wait methods that will allow us to retry complex conditions.
The WebDriverWait class and methods
Before we start writing our aggregated wait methods, we need to look a little bit at the WebDriverWait class from Selenium. It allows us to create custom wait methods in our tests, where we can wait for all sorts of conditions to be fulfilled, like a WebElement to be displayed, or the text on a WebElement to equal a certain String, and so on. When creating your wait methods you might use some of the ExpectedConditions methods that exist in the Selenium library, or you might write some custom code yourself.