本文档描述了一系列类, 这些类用于明确指定在测试中需要等待的各种条件.
wait = WebDriverWait(driver, timeout=2) wait.until(EC.visibility_of_element_located((By.ID, "revealed")))
examples/python/tests/support/test_expected_conditions.py
from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait # Expected Conditions API Documentation: # https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html def test_expected_condition(driver): driver.get("https://www.selenium.dev/selenium/web/dynamic.html") revealed = driver.find_element(By.ID, "revealed") driver.find_element(By.ID, "reveal").click() wait = WebDriverWait(driver, timeout=2) wait.until(EC.visibility_of_element_located((By.ID, "revealed"))) revealed.send_keys("Displayed") assert revealed.get_property("value") == "Displayed"
.NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy.
Ruby makes frequent use of blocks, procs and lambdas and does not need Expected Conditions classes