显示等待
https://www.cnblogs.com/jiyanjiao-702521/p/9636616.html
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from time import sleep driver=webdriver.Chrome() driver.get("http://www.baidu.com") driver.find_element_by_css_selector("#kw").send_keys("python") sleep(2)
#driver=WebDriver的意思 5表示超时间 0.5表示每0.5秒检测一次
#until(EC.presence_of_element_located((By.ID,"su"))) 表示直到找到元素 su 为止,使用By.ID的方法来找
element=WebDriverWait(driver,5,0.5).until(EC.presence_of_element_located((By.ID,"su")))
element.click()
sleep(2)
driver.quit()