Reputation: 159
Example: To wait for
<select id="myselect"></select>
to be populated with
<option value="123">One-two-three</option>
How can I do it in Python?
Upvotes: 4
Views: 6101
Reputation: 6518
You can use presence_of_element_located
and explicit waiting to locate the element with a css selector:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, "option[value='123']"))
)
print("Option loaded")
except TimeoutException:
print("Time exceeded!")
# Do Your Stuff
Upvotes: 9