Here are some Python implementations of the WebDriverWait methods that I use in my TestSuite
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import WebDriverException
def wait_for_element_by_class(driver, element, wait_time=5):
return WebDriverWait(driver, wait_time).until(
EC.presence_of_element_located((By.CLASS_NAME, element)))
def wait_for_dismiss_element_by_class(driver, element, wait_time=5):
return WebDriverWait(driver, wait_time).until_not(
EC.presence_of_element_located((By.CLASS_NAME, element)))
def wait_for_element_by_name(driver, element_name, wait_time=5):
return WebDriverWait(driver, wait_time).until(
EC.presence_of_element_located((By.NAME, element_name)))