Implicit and Explicit Wait
There are two types of waiting mechanism available in Selenium
- Explicit Wait
- Implicit Wait
Explicit Wait
- Explicit Wait will make your code to wait for certain condition to occur before moving forward.
- This can be achieved with the combination of WebDriverWait and ExpectedConditions
- WebDriverWait by default calls ExpectedCondition to poll by every 500
milliseconds until it returns successfully.
Code Snippet
public static void ExplicitWait(WebDriver driver, WebElement element) {
(new WebDriverWait(driver, 10)).until(ExpectedConditions.visibilityOf(element));
}
Implicit Wait
- Implicit wait make the code to wait for an element to appear in DOM
- Implicit wait timeout once set, is set for the lifetime of the WebDriver Object Instance.
Code Snippet
public static void ImplicitWait(WebDriver driver) {
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
Thanks for reading the post and watching the video !!!
Please share your comments to improve the post.
Thanks,
Karthik KK