EC.element_to_be_selected
时间: 2023-09-18 22:12:32 浏览: 67
EC.element_to_be_selected is a condition in Selenium WebDriver's Expected Conditions class that checks if a web element is selected or not. It returns True if the element is selected, otherwise, it returns False. This condition is useful when we want to wait for an element to be selected before performing any action on it.
Example usage:
```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 for the element with id 'checkbox1' to be selected
wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_selected((By.ID, 'checkbox1')))
```
In the above example, we are waiting for the element with id 'checkbox1' to be selected using the EC.element_to_be_selected condition. The wait will timeout after 10 seconds if the element is not selected. Once the element is selected, the wait will end and the element will be returned.