Selenium Wait Until Element Ready (Python)

Dec 22, 2018

Wait until element presence by class name

from import WebDriverWaitfrom 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("")english_link = driver.find_element_by_css_selector("#js-link-box-en")


❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.