Peter W.
Peter W.

Reputation: 137

Python Selenium implicit wait

Is there a difference between:

self.driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

OR

self.driver.implicitly_wait(10) # seconds

Why does this 15 value explicit wait not over-ride the 10 seconds? Or is it the case once implicit is specified, it ignores the explicit?

btn = WebDriverWait(driver, 15).until(
         lambda wd: wd.find_element_by_css_selector('someCSS')  )

Any advice?

Upvotes: 1

Views: 6326

Answers (1)

Max Daroshchanka
Max Daroshchanka

Reputation: 2978

From: https://selenium-python.readthedocs.io/waits.html#implicit-waits

An implicit wait tells WebDriver to poll the DOM for a certain amount of time when trying to find any element (or elements) not immediately available.

This syntax should be used for python:

self.driver.implicitly_wait(10) # seconds

Implicitly wait behavior is a very low level so it will affect other operations, like explicit waits.

This will work 100 seconds if no such element:

self.driver.implicitly_wait(100) # seconds
btn = WebDriverWait(driver, 10).until(
         lambda wd: wd.find_element_by_css_selector('someCSS')  )

This will work 20 seconds if no such element (need to recheck):

self.driver.implicitly_wait(10) # seconds
btn = WebDriverWait(driver, 11).until(
         lambda wd: wd.find_element_by_css_selector('someCSS')  )

This will work 15 seconds if no such element:

self.driver.implicitly_wait(5) # seconds
btn = WebDriverWait(driver, 15).until(
         lambda wd: wd.find_element_by_css_selector('someCSS')  )

Upvotes: 2

Related Questions