During my talk at the recent SauceCon conference, i described how you can write reliable Selenium tests by using WebDriverWait based methods to wait for page events to take place. I am now happy to announce that my little project, thewaiter library that i mentioned in the talk, is available to use from the Maven Repository! Read on for details.

Introducing thewaiter

The library is made up of just one class that holds a ton of wait based methods, to help you design reliable and shorter Selenium tests. I will write several blog posts describing the purpose of those methods, but just to give you an idea, the methods included in the library will help you wait for:

  • page load complete
  • URLs (to equal or contain a String, taking the case into account or not)
  • a WebElement to be clickable and to actually click on it
  • a WebElement text to equal/contain an expected String, ignoring or taking into account the case or whitespaces
  • a WebElement attribute’s value to equal/contain an expected String, ignoring or taking into account the case or whitespaces
  • some click and wait methods are also present, like clicking on a WebElement and waiting for a URL (to equal or contain an expected String)
  • and so on

And this is just in the first version of the library! Further releases will bring even more goodness.

All the methods that are available are well documented, so don’t hesitate to read the Javadoc once you imported the library into your project.

Where to find the library

Version 1.0 of the library was just released to the Maven Repository. You can find it here:


The GitHub repo of the project (and the place where you will find some documentation) is:


Importing thewaiter into your project

In order to import the library into your Maven project, just add the following entry in your pom.xml file, in the dependencies section:


The waiter library has Selenium as a dependency, so in order to avoid dependency management issues, the “exclusion” section needs to be added. This way, you can control from your own dependency the Selenium version you want to import into your project.

Using Waiter in your test

After you imported the library as a dependency, you can start creating the tests that will use it. In the class where you will use it, you first need to import the Waiter class, as follows:

import waiter.Waiter;

You also need to instantiate the Waiter class:

private Waiter waiter = new Waiter();

In the test, you just need to call the method that you want from the Waiter class, with the corresponding parameters. Some examples:

waiter.get(theUrl, theDriverInstance);

waiter.waitForElementTextEqualsString(webElement, expectedString, theDriverInstance);

waiter.waitForElementAttributeContainsString(webElement, theAttribute, expectedString, theDriverInstance, 10);

waiter.click(webElement, theDriverInstance);
waiter.clickElementAndWaitForUrlContains(webElement, expectedString, theDriverInstance);

Note that for methods that take a WebElement as parameter, you need to pass it as a PageObject variable, not as “driver.findElement(…)” because the latter will not work.

Further reading

I will write quite a few posts on the blog to exemplify the usage of the methods, so stay tuned. Also, the examples will be uploaded to another of my GitHub projects, here:


You can also take a look at the talk in which i describe how to use the wait methods to write reliable tests:



5 thoughts on “Introducing thewaiter. A WebDriverWait based library for writing reliable Selenium tests

      1. A default wait time is set in the Waiter class in the constant called TIMEOUT. It basically means the same thing: default wait time. The tests will wait up to the TIMEOUT value in seconds.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.