Skip to main content

Selenium WebDriver Synchronization

TLDR; Learning effective synchronisation strategies makes your automated execution more reliable.

One of the most important skills I have developed for automating was learning how to synchronise. And we often spend time working on this for automation consultancy engagements because it is a fast way to improve the trust in the execution.

Learn to Sync Well

Supporting Video

Why This Course?

When I perform consultancy for Test Automation I get to see a lot of code from different companies.

And while people often understand the WebDriver API and they understand how to code, the synchronisation approaches in use often lack variety, are inappropriate for the application, or lead to intermittent execution.

Intermittent execution is often known as ‘flaky’ tests. The tests run, but periodically they fail.

This can lead to a lack of trust in the automation, or the use of retry strategies e.g. rerun the test and see if it passes.

There are multiple reasons why this can occur, with synchronisation beinge one of them: data setup, interference from other tests, parallel execution, environment stability, underlying bugs.

But… under these circumstances, one of the first things I look for is how is the code synchronising on application state.

Variety of Approaches

Because there are so many ways of synchronising application state I wanted to create a course which provides an overview and examples of as many approaches as possible. While also weaving in the theory and broader perspective as we explore code implementation examples.

To support the course I created a custom application called “The SyncHole”:

This application offers a number of ’tricky’ synchronisation situations triggered by both JavaScript, CSS, XMLHttpRequest/Fetch network requests.

The course explains:

  • Why we don’t use Thread.sleep.
  • When does WebDriver automatically wait.
  • Implicit Waits vs Explicit Waits
  • Built in Synchronisation classes WebDriverWait and ExpectedConditions
  • Custom synchronisation conditions.
  • Synchronsing with Java closure patterns
  • Synchronising using JavaScript from WebDriver
  • Creating abstractions and libraries for synchronisation.
  • External libraries to help with Synchronisation and learn from.
  • Additional synchronisation considerations for Remote WebDriver.

All of this with hands on coding examples and additional theory discussions.

I crammed in the most common approaches to synchronisation that I encountered and discuss their pros and cons.

The course is available as part of a Linkedin learning subscription or as a stand alone purchase.

Learn to Sync Effectively