硒waitForElement

硒waitForElement,第1张

硒waitForElement

从硒文档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)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5617260.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存