Wait until element presence by class name
from selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECel = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.CLASS_NAME, "confirmation-box")))
NOTE: By supports ID
, CSS_SELECTOR
, NAME
, etc.
Wait until element ready to be clicked
el = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.CLASS_NAME, "confirmation-button")))
NOTE: expected_conditions supports invisibility_of_element
, visibility_of
, title_is
, url_changes
, etc.
If you just want to wait without any conditions.
import timetimer.sleep(1)
You can set an implicit wait (it will automatically wait n seconds for any elements not available immediately).
driver.implicitly_wait(10)driver.get("https://www.wikipedia.org/")english_link = driver.find_element_by_css_selector("#js-link-box-en")
References: