over 8 years ago
Different types of Selenium WebDriver Waits:
Waits helps the user to solve the issues which comes while redirecting to different web pages, by refreshing the web page and reloading the new web elements. At times there can be Ajax calls as well. So, a time delay occurs while reloading the web pages and reflecting the web elements.
WebDriver provides two types of waits to handle the loading of reappearing page & web element, windows appearance, pop ups and error messages and display of web elements on the web page:
1. WebDriver Implicit Wait:
Implicit waits are utilize to provide a default waiting time into each following test step/command over the complete test script. So, the next test step will be performed when the 30 seconds have passed after the previous test step.
Key Notes:
It is easy and simple to apply but it has some drawbacks as well. It increases the test script execution time as each command will stop to wait for a specified time before restart the execution.
Import Statements:
import java.util.concurrent.TimeUnit – We have to import this package before applying the implicit wait.
Syntax:
drv.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
2. WebDriver Explicit Wait:
It is used to stop the execution until the time for a particular condition is met or the maximum time has passed. Also, it is only applied for a particular case.
WebDriver has two classes to apply the Explicit waits into the test scripts:
Import Statements:
We have to import this package before applying the explicit wait:
import org.openqa.selenium.support.ui.ExpectedConditions
import org.openqa.selenium.support.ui.WebDriverWait
Can you help out the community by solving one of the following Automation problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)