from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC # Wait for the element with id "myButton" to be visible wait = WebDriverWait(driver, 10) element = wait.until(EC.visibility_of_element_located((By.ID, "myButton"))) # Click the button element.click()
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC # Wait for the page title to contain "google" wait = WebDriverWait(driver, 10) title = wait.until(EC.title_contains("google")) # Perform other actions on the pageIn this example, we are using WebDriverWait to wait for the page title to contain the word "google" before proceeding with other actions on the page. In both examples, we are using the expected_conditions module from the selenium.webdriver.support package to specify the condition that we want to wait for. We are also specifying how long to wait (in seconds) using the WebDriverWait class.