Using Implicit Waits to Improve your Regression Test Automation

The number of test scripts and associated libraries continues to grow as users expand their usage of Awetest (or any Automation framework/tool for that matter). As the volume of your Regression Test Automation assets (scripts, libraries, data sources, etc.) grows it becomes imperative to build your automation in a way that is scalable and dependable, minimizing the “false positives” and reducing the maintenance overhead- a simple way of doing this is by using the Watir WebDriver implicit wait.

Sleep functions and explicit waits, wherein the script waits for a pre-defined period duration (e.g. 10 seconds) creates a slow running test, which is not ideal for a variety of reasons. In addition to tests running slower, there is a good chance the tests might fail in special conditions (slower connection, increased load on the network, slower/older machine, etc.). So instead of using explicit waits, the test should wait for specific events rather than for a page to load, or artificially wait ‘x’ seconds.

Use Functions

Using functions simplifies the coding process and I suggest you use them whenever possible. Functions are reusable and can be called across hundreds of tests, making it easier to manage your automation. Whenever your application changes , you would have to change the code in the one function, rather than search throughout the code for all of the repeated code and change each script.

Waiting for Ajax

If your application, like many of the popular apps today, uses a lot of ajax and JavaScript then Watir WebDriver’s page load detection capabilities are not as useful for your automation. However, Watir WebDriver’s <wait_while_present> function can prove to be very useful in these situations. When your application is loading an ajax call then it is good to visually have an ajax loader animation displayed, and the <wait_while_present> function allows for you to take advantage of this. Below are some of the different Watir Webdriver “wait” commands you can make use of to scale your Regression Test Automation.


Applications, especially earlier in the Software Testing Life Cycle will timeout for a variety of reasons. You can handle this by using the ruby class. This works especially well when you have a set SLA for page load times. You can use it in conjunction with the <wait_while_present> function to facilitate situations where you can fail the test if it the page doesn’t load within ‘x’ seconds.

Logging Errors

A useful tip is to log all errors to a file, you can achieve this by overriding the test-unit method at the top of your test script. Awetest provides a lot of logging directly inside the reporting section. In addition to that Awetest publishes the Worker logs directly in the Jobs section as shown below.



Retrying Errors

As with timeouts, even with great tests a random error could fail the test for no traceable reason. To help with this invisible problem you can write a script that will retry all of the errors that you have just logged in the previously mentioned tip. Again, Awetest’s ability to selectively execute tests gives you the ability to review the reports & logs and re-run the entire job over or simply the tests that failed.


Writing good tests compared to bad ones could result in great success in your Regression Test Automation efforts with increased speed and efficiency, and reliability! By rewriting your code using these tips you will see improvement in not only speed, but stability as well when running your entire testing suite. We saw a 30+% reduction in end-to-end run times by introducing simple Watir WebDriver implicit waits – translating into a 200+ hour reduction in automation runs every month!