class selenium.webdriver.support.wait.WebDriverWait(driver, timeout, poll_frequency=0.5, ignored_exceptions=None)
参数:Driver:WebDriver的驱动程序
Timeout:最常超是时间,默认以秒为单位
Poll_frequency:休眠时间的间隔时间,默认为0.5秒
Ignored_exception:超时后的异常信息,默认情况下抛NoSuchElementException异常。
例子:
from selenium.webdriver.support.wait import WebDriverWait
element = WebDriverWait(driver, 10).until(lambda x: x.find_element_by_id(“someId”))
is_disappeared = WebDriverWait(driver, 30, 1, (ElementNotVisibleException)).
until_not(lambda x: x.find_element_by_id(“someId”).is_displayed())
until(method, message='')
:调用该方法提供的驱动程序作为一个参数,直到返回值为True。
until_not(method, message='')
:调用该方法提供的驱动程序作为一个参数,直到返回值为false。
找到一篇很好的文章:http://blog.csdn.net/henni_719/article/details/51131076