What is Synchronization ?
When two or more components work together, they should work in sync in order to achieve the desired result. If those components are not working in parallel or in sync, you may not get expected result. So, working of those components in sync or in parallel is termed as Synchronization.
In case of selenium test automation, there are two things who should work in parallel or in sync.
1. Application Under Test (AUT)
2. Testing tool (here, let us consider as Selenium)
Now, both of these two things (AUT & Selenium) have their own speed. Selenium Webdriver may be faster, but in some of the cases, application under test, takes some time for page load, or for web elements to be present on the webpage. In this case, Selenium Webdriver may not find those elements since the speed of Selenium Webdriver is faster as compare to Application (suppose). So here your tests will fail.
In order to overcome this situation, Application Under Test (website that you are testing) and your testing tool (Selenium in this case) should have same working speed. So, to match the speed of the application or in some case, to wait for specific conditions at some point of time, we use Synchronization, which helps to bring the AUT & Testing tool speed in sync. Now “Element Not Found” Error may not arise.
One of the way to implement wait is by calling thread.sleep() function however, it is not recommended because this is not very stable and unreliable. The time has to be specified in milliseconds.
There are 2 ways to Achieve Synchronization.
1. Implicit wait
2. Explicit wait
To understand about types of the wait, below links describe the Implicit and Explicit wait in more details –
What is Implicit wait? How to Achieve Implicit wait in Selenium?
What is Explicit wait? How to Achieve Explicit wait in Selenium?
What is Fluent wait? How to Achieve Fluent wait inSelenium?
Which is the best wait in selenium WebDriver?
Hope This Helps !!!!!