selenium three waiting methods

When Python+selenium implements webUI automation, when an exception is caused by the page loading speed, it can be solved by waiting; there are three commonly used waiting methods: 1. Forced waiting 2. Explicit waiting 3. Implicit waiting

#Force wait 

module: time

Statement block: sleep(*)

Note: Forced to wait * seconds, no matter whether the page is loaded within * seconds, proceed to the next step

Features: Too mechanical affects efficiency

#implicit wait 

Module: webdriver

Statement block: driver.implicitly_wait(*)

Note: * is the maximum waiting time. If the page is loaded within the specified time, the next step will be executed, otherwise it will wait until * seconds.

Features: When waiting for the page to load, all resources including js are loaded, and it acts on the entire driver cycle

# explicit wait

模块:selenium.webdriver.support.wait.WebDriverWait

Statement block: WebDriverWait(driver, total duration, interval duration, ignore exception (optional)).until()

Reference URL: https://blog.csdn.net/huilan_same/article/details/52544521

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325725766&siteId=291194637