3

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?

1 Answer 1

2

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.