Explicit Waits

Setting Explicit Waits

An explicit wait is a test condition that  you define to wait for a certain condition to occur before proceeding further in the code. The worst case of this is time or sleep, which sets the condition to an exact time period to wait. There are some convenient methods provided that help you write code that will wait only as long as required. 


Sauce Labs understands that most of the web apps are using AJAX techniques. When a page is loaded to browser, the elements within that page may load at different time intervals. This makes locating elements difficult, if the element is not present in the DOM, it will raise ElementNotVisibleException exception. Using waits, we can solve this issue. Waiting provides some time interval between actions performed - mostly locating element or any other operation with the element.


Selenium Webdriver provides two types of waits - implicit & explicit. An explicit wait makes WebDriver to wait for a certain condition to occur before proceeding further with executions. An implicit wait makes WebDriver to poll the DOM for a certain amount of time when trying to locate an element.


Download the white paper today and begin testing with Sauce Labs.