Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Is it best practice to use Thread.sleep() or explicit wait before click on any element in selenium web driver

Category: Selenium WebDriver

Using explicit wait/implicit wait is the best practice, Lets check what actually the explicit wait,Thread.sleep(), Implicit wait’s working logic.

Explicit wait: An explicit waits is a kind of wait for a certain condition to occur before proceeding further in the code.

Implicit wait: An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0

Thread.sleep() In sleep code will always wait for mentioned seconds in side the parentheses even in case working page is ready after 1 sec. So this can slow the tests.

Leave a Reply

Your email address will not be published. Required fields are marked *