ImplicitWait:
1. Static Wait 2. UnConditional Wait (No conditions are given) 3. Applicable throughout the program
Java implicit wait declaration - Selen:
driver.manage().timeout().implicitWait(20, TimeUnit.Seconds());
When to use implicit Wait?
Implicit wait is not recommended to be used anywhere in the automation package, since it is static, and we do not know when the web element will appear on the website.
i.e. Suppose you set the implicit wait to 5 seconds, and the driver can identify the web element in 2 seconds, since we used the implicit wait driver, which will wait another 3 seconds (up to 5 seconds). This will slow down the automation process.
Explicit Expectation:
- Dynamic wait
- Conditional wait.
- Not applicable throughout the program.
Declare an explicit wait in Java Selenium.
WebDriverWait wait=new WebDriverWait(driver, 20); wait.until(somecondition);
When to use explicit wait?
We should always use explicit expectation, since it is dynamic.
i.e. Suppose you set an explicit wait of 5 seconds, and the driver can identify the web element in 2 seconds, because we used an explicit wait driver that will not wait another 3 seconds (up to 5 seconds). The driver will continue to work after 2 seconds. This will speed up the automation process.
Kiran Sk May 16 '17 at 18:15 2017-05-16 18:15
source share