WebDriverWait().until()
时间: 2023-11-08 11:04:14 浏览: 127
Python自动化测试系列[v1.0.0][智能等待]
WebDriverWait().until() is a method used in Selenium WebDriver to wait for a specific condition to be met before proceeding with the script execution. The method takes in a condition as an argument and waits until the condition is true or a timeout occurs.
Example usage:
```
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
# Wait for an element to be clickable
element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'my-button')))
# Wait for a URL to contain a specific string
WebDriverWait(driver, 10).until(EC.url_contains('example.com'))
# Wait for an alert to be present
alert = WebDriverWait(driver, 10).until(EC.alert_is_present())
```
阅读全文