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 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:

importwaiter.Waiter;

You also need to instantiate the Waiter class:

privateWaiter waiter =newWaiter();

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