I am using selenium webdriver with python.
I would like to create an explicit wait for a popup window to appear. Unfortunately, the common methods of the EC module do not include a ready-made solution for this problem. Searching many other posts, I gather that I have to write my own EC condition, with
.until(new ExpectedCondition() { * the condition and its return arguments *}.
I am having trouble finding documentation regarding the exact syntax to use to write this properly. There is a java example here: https://groups.google.com/forum/#!msg/selenium-users/iP174o0ddw4/l83n5C5rcPoJ. Could somebody either point to the relevant documentation (not on waits generally, but on creating new EC), or simply help me write the python version if the java code I just linked to. Thanks a lot
If you want to wait for arbitrary conditions, you don't have to use ExpectedCondition at all. You can just pass a function to the until method:
from selenium.webdriver.support.ui import WebDriverWait
def condition(driver):
ret = False
# ...
# Actual code to check condition goes here and should
# set `ret` to a truthy value if the condition is true
# ...
return ret
WebDriverWait(driver, 10).until(condition)
The code above will call condition repeatedly until either of the following is true:
condition returns a value that evaluates true,
10 seconds have elapsed (in which case an exception is raised).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With