Let's consider time out is 10 sec.
Element found in 3 sec.
In all three wait cases what would be response of webdriver
Let's consider time out is 10 sec.
Element found in 3 sec.
In all three wait cases what would be response of webdriver
In general, despite of what kind of method you choose, program will continue once element was found.
The difference between whose three methods is WHEN will the driver find the element.
see also Differences between impilicit, explicit and fluentwait
And I just make a little example compared these there methods with python (If there's any different result using Java to implement this, please let me know)
**I build a blank page and a piece of scripts which product a block with id="new_elem" after 3 seconds.**And I use PhantomJS as selenium driver.
I would like to present the time those methods processing the find elements task first.
Fluent wait, 1s interval: waited 3.076176 seconds
Fluent wait, 5s interval: waited 5.587320 seconds
Explicit wait, 10s wait time: waited 3.105178 seconds
Implicit wait, 10s wait time: waited 3.138179 seconds
1.1 Fluent Wait with 1 second interval
start = time.time()
driver.get('http://127.0.0.1:5000')
element = WebDriverWait(driver, 10, poll_frequency=1).until(EC.presence_of_element_located((By.ID, 'new_elem')))
print("Fluent wait, 1s interval: waited %f seconds" % (time.time()-start))
After 3 seconds, the driver found the element.
1.2 Fluent Wait with 5-second interval
start = time.time()
driver.get('http://127.0.0.1:5000')
element = WebDriverWait(driver, 10, poll_frequency=5).until(EC.presence_of_element_located((By.ID, 'new_elem')))
print("Fluent wait, 5s interval: waited %f seconds" % (time.time()-start))
The driver did not find the element immediately after the element shows up, but after a 5-second interval.
2. Explicit Wait with 10-second wait time
start = time.time()
driver.get('http://127.0.0.1:5000')
element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'new_elem')))
print("Explicit wait, 10s wait time: waited %f seconds" % (time.time()-start))
In default, the polling interval of WebDriverWait is 0.5 seconds. So the driver found the element right after 3 seconds.
3 Implicit Wait with 10-second wait time
start = time.time()
driver.implicitly_wait(10)
driver.get('http://127.0.0.1:5000')
element = driver.find_element_by_id('new_elem')
print("Implicit wait, 10s wait time: waited %f seconds" % (time.time()-start))
Please notice, implicitly waiting time is a global setting option. Once set, whenever call find_element method, it will wait up to waiting time before find the element. But once it find the target, it will return the result and wait no more time.
Also, you could not set polling interval with implicitly wait. It will just keep trying polling certain elements from DOM with short time intervals.