3

selenium中的隐式等待

 3 years ago
source link: https://segmentfault.com/a/1190000040622091
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

selenium中的隐式等待

发布于 28 分钟前
from selenium import webdriver
  self.driver = webdriver.Chrome()
  self.driver.implicitly_wait(10)
  self.driver.maximize_window()
  self.driver.get("https://magento.com/products/magento-open-source")

1.由于网络延时或者动态加载元素导致页面无法短时间显示,使用隐式等待是很有效的解决办法。隐式等待的默认时间是0s,本例中,设置等待时间为10s,这10s并非固定的等待时间,而是如果在第5s中搜到DOM元素,则接着往下执行,如果10s后还没定位到元素,那么抛出NoSuchElementException异常。
2.一旦设置隐式等待,将作用于WebDriver实例的整个生命周期。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK