元素等待之---隐式等待
from selenium import webdriver
#导入找不到元素抛出异常说所需要的类
from selenium.common.exceptions import NoSuchElementException
from time import sleep,ctime
driver=webdriver.Firefox()
driver.get("http://www.baidu.com")
sleep(2)
#针对的全局的隐式等待
driver.implicitly_wait(5) #隐式等待时间设定 5秒
#检测搜索框是否存在
try:
print(ctime())
driver.find_element_by_css_selector("#kw").send_keys("Python")
driver. find_element_by_css_selector("#su").click
except NoSuchElementException as msg:
print(msg)
finally:
print(ctime())
sleep(3)
driver.quit()
标签:driver,---,sleep,print,等待,隐式
From: https://www.cnblogs.com/hahaniuer/p/16870249.html