24. Robust Synchronization: WebDriverWait & Expected Conditions

WebDriverWait in Python

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

wait = WebDriverWait(driver, timeout=10)

# Wait until element is visible:
banner = wait.until(EC.visibility_of_element_located((By.ID, "welcome-banner")))

# Wait until clickable:
submit_btn = wait.until(EC.element_to_be_clickable((By.ID, "submit-btn")))
submit_btn.click()

Task

  • Implement wait_for_clickable(driver, locator, timeout=10):
  • 1. Return WebDriverWait(driver, timeout).until(EC.element_to_be_clickable(locator)).
πŸ’‘Common doubts
Did you like the problem?
Lesson 24 of 43
Python
Loading code editor…
Next