Selenium Wait Until Element Ready (Python)

December 22, 2018

Wait until element presence by class name

from import WebDriverWait
from import expected_conditions as EC

el = 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 time

You can set an implicit wait (it will automatically wait n seconds for any elements not available immediately).

english_link = driver.find_element_by_css_selector("#js-link-box-en")


This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.