SeleniumLab

Course1 · Selenium automation → Waits

1 · Selenium automation

Explicit waits with WebDriverWait

14 min · Module 9

Dynamic pages need waits. Prefer WebDriverWait + expected conditions over time.sleep().

On the dynamic lab, click Load data and wait until #result is visible (about 2 seconds).

Example / notes

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

driver = webdriver.Chrome()
driver.get("http://127.0.0.1:8000/lab/dynamic/")
driver.find_element(By.ID, "load-data").click()

result = WebDriverWait(driver, 5).until(
    EC.visibility_of_element_located((By.ID, "result"))
)
print(result.text)
driver.quit()

Practice in Lab: /lab/dynamic/

Log in to track progress / take quizzes
Modules in this track