def wait_for(self, condition, *args, **kwargs):
"""Waits until `condition` is satisfied. If `condition` is not satisfied after a timeout period of 2 seconds,
an exception is raised.
:param condition: A function, method or other callable which will be called periodically to check\
whether a certain condition holds. It should return True if the condition holds,\
False otherwise.
Extra positional and keyword arguments to this method are passed on as-is in the calls
to `condition`.
"""
def wrapped(driver):
try:
return condition(*args, **kwargs)
except Exception as ex:
if isinstance(ex.args[0], CannotSendRequest):
return False
raise
return WebDriverWait(self.web_driver, 2).until(wrapped)
评论列表
文章目录