简体   繁体   中英

Selenium webdriver find_element_by_xpath takes time

If element does not exist on the page find_element_by_xpath() takes too much time hanging the test execution. Is there any way to set timeout to find_element_by_xpath() function in python?

You can set an implicit wait using this code -

ff = webdriver.Firefox()
ff.implicitly_wait(10) # seconds

This makes the WebDriver wait for 10 secs before raising an error when you try to find an element on the webpage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM