Selenim learning: setting element wait
Show wait
Show wait for Webdriver to continue execution when a condition is established, otherwise a timeout exception is thrown when the maximum length of time is reached (TimeoutException)
From selenium import webdriverfrom time import * from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as EC# renamed expected_conditions to ECdriver = webdriver.Chrome () url = 'http://www.baidu.com'driver.get(url)element = WebDriverWait (driver,5,0.5). Until (EC.presence_of_element_located ((By.ID,'kw')) element.send_keys (' selenium') sleep (5) driver.quit ()
The WebDriverWait class is a wait method provided by WebDriver. Within the set time, by default, whether the current page element exists is detected by default, and an exception is thrown if it cannot be detected beyond the setting time.
2.sleep method
The sleep () method is provided by the time module of python