Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果页面上不存在元素会find_element_by_xpath()花费太多时间挂起测试执行。有没有办法设置超时以find_element_by_xpath()在 python 中运行?
find_element_by_xpath()
您可以使用此代码设置隐式等待-
ff = webdriver.Firefox() ff.implicitly_wait(10) # seconds
当您尝试在网页上查找元素时,这会使 WebDriver 在引发错误之前等待 10 秒。