【python+selenium】三种等待方式

1.time.sleep(1):强制等待1s,使用效果明显但是脚本执行也变慢不少

2.隐式等待:使用一次后全程生效

1 def wait(self,seconds):
2     self.driver.implicity_wait(seconds)

3.显式等待

from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

element=WebDriverWait(driver,10,1).until(EC.visibility_of_element_located((By.XPATH,'元素定位')))

三种结合起来使用

原文地址:https://www.cnblogs.com/jinziguang/p/14579021.html