Reputation: 286
I know about the solution with
elem = WebDriverWait(browser, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, ".reply-button"))).click()
But here you would wait 20 seconds and then it would either load the element in a variable or throw an exception.
Is there any blocking
solution which stops the program until the element is visible?
Upvotes: 3
Views: 5163
Reputation: 33361
First of all WebDriverWait
will not wait 20 seconds.
It returns web element matching the passed locator, .reply-button
css_selector in your case, at the moment Selenium detects that element presence.
It will wait for the defined timeout period only if no element found.
As about the element visibility, there is a similar expected condition waiting for element to be visible, like this:
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.reply-button')))
This will block the flow execution exactly until the element located by .reply-button
css_selector is found to be visible or for the timeout, the first of the above.
Upvotes: 2