selenium+python等待时间

等待时间可以有多种

1.硬等待

import time

time.sleep(x)#等待x秒

2.浏览器每次查找一个元素都进行等待

import time

br.implicitly_wait(x)#在x秒内不断的去搜索需要找的元素

3.针对某一个元素的等待

from selenium.webdriver.support.ui import WebDriverWait

#__init__(self, driver, timeout, poll_frequency=0.5, ignored_exceptions=None)

element = WebDriverWait(driver, 10).until(lambda x: x.find_element_by_id("someId")) 


is_disappeared = WebDriverWait(driver, 30, 1, (ElementNotVisibleException)).until_not(lambda x: x.find_element_by_id("someId").is_displayed()) 

原文地址:https://www.cnblogs.com/hungerboy/p/6742888.html