What is Synchronization?


Synchronization, in General, is termed as a method of combining multiple processes at a certain point which helps to get the desired output.

It is a technique which helps many components works parallel to each other.

Check here the other Important Topics in Selenium.

Why is Synchronization needed?


As an automation tester, while testing an application, It is very much important to run your automation testing tool parallel with your Application under test in order to get 100% result.

Similarly,

If the AUT runs slowly but the testing tool commands are running fast it results in an error. To fix this it is needed to make the testing command wait.

Which means?

We are telling the Testing Tool to wait for a particular time before moving to the next code.

This is called Synchronization in Selenium. It is much required nowadays because of usage of different technologies such as AngularJS, AJAX.

Selenium Synchronization Infographics

selenium synchronization

Synchronization Types in Selenium


There are two different types of Synchronization they are,

  • Unconditional Synchronization
  • Conditional Synchronization

Unconditional Synchronization

In this method, we will make the tool command to wait for a specific amount of time. Using the below commands,

Wait() & Thread.Sleep();

The issue we face here is the waiting time which is not required, in other words, it exceeds the required time period.

Conditional Synchronization

Conditional Synchronization is nothing but the same as Unconditional Synchronization in addition with a specific condition.

Here while adding the timeout value, a condition is also been added to it.


FREE PDF Download:
Selenium Course Content

The Waiting Game


Three different types of wait which are commonly used are as follows,

    • Implicit Wait
    • Explicit Wait

Implicit Wait

Implicit Wait is used to inform the WebDriver to pause the DOM, but for a specific time period until finding the element.

This Implicit Wait technique can be used only to find the elements, It will work for the be Find Element, Find Elements statements,

How does it work?

The process of Implicit Wait is, If an Implicit Wait is set you may not think that it will throw an error report(exception) in case the element which is looking for is not found.

Instead;

It will wait until it finds the Element throughout the timeout period.

Explicit Wait

If we need to make the statement wait for a certain condition to be successful, then Explicit Wait is the option for you.
Explicit Wait is especially used in a part where the content or the attribute of the page needs to be changed by the action from UI.

Ex:
Country – State Drop Down option used in forms.

Points to Remember:

      • Makes many components work parallely.
      • Automation Testing Tool works parallely with the Application Under Test.
      • Testing Tool to wait for a particular time before moving to the next code.
      • There are two different types of Synchronization.

Having Queries in Selenium? Ask here to get Expert Answers – Selenium FAQs