Posts

Showing posts with the label Selenium

Sin of Using Thread.sleep() in Selenium Scripts for Waits

Wait problem is probably the most common errors in Selenium scripts especially for Javascript rich web applications. How long a Selenium script should wait before interacting with web elements? 2s / 5s / 15s / 1min? Until interested page is loaded? Until all images of a page are downloaded? Until all AJAX requests have been completed? Until all manipulation of DOM elements is complete? It has been observed that people frequently wait for a fixed duration in their Selenium script using Thread.sleep() function before interacting with a web element. It is a worst kind of wait that can be used in a script. Then, why people use it? One reason could be ignorance but mostly it could be due to carelessness or unavailability of time to complete a quality (stable) script. What are some ways to discourage team members to not use Thread.sleep() or similar method in t