gpt4 book ai didi

python - Selenium Python 如何等待选择中的选项被填充?

转载 作者:行者123 更新时间:2023-11-28 22:26:00 25 4
gpt4 key购买 nike

例子:WAITING

<select id="myselect"></select>

填充

<option value="123">One-two-three</option>

如何在 Python 中完成?

最佳答案

您可以使用 presence_of_element_locatedexplicit waiting使用 css 选择器定位元素:

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

关于python - Selenium Python 如何等待选择中的选项被填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45134933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com