从硒文档PDF:
import contextlibimport selenium.webdriver as webdriverimport selenium.webdriver.support.ui as uiwith contextlib.closing(webdriver.Firefox()) as driver: driver.get('http://www.google.com') wait = ui.WebDriverWait(driver,10) # Do not call `implicitly_wait` if using `WebDriverWait`. # It magnifies the timeout. # driver.implicitly_wait(10) inputElement=driver.find_element_by_name('q') inputElement.send_keys('Cheese!') inputElement.submit() print(driver.title) wait.until(lambda driver: driver.title.lower().startswith('cheese!')) print(driver.title) # This raises # selenium.common.exceptions.TimeoutException: Message: None # after 10 seconds wait.until(lambda driver: driver.find_element_by_id('someId')) print(driver.title)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)