You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python Selenium下拉框问题:无法选择Wayne RESA (82)选项

解决方案

你遇到的问题根源是这个网站的ISD下拉框不是原生HTML <select> 元素,而是用自定义UI组件模拟的,所以Selenium的Select类无法识别和操作它。换用直接定位目标选项并点击的方式即可解决:

# 导入所需模块(确保已导入)
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# 等待下拉框可点击并点击展开选项列表
isd_dropdown = WebDriverWait(browser, 10).until(
    EC.element_to_be_clickable((By.ID, "isds"))
)
isd_dropdown.click()

# 等待目标选项可点击并执行选择
target_option = WebDriverWait(browser, 10).until(
    EC.element_to_be_clickable((By.XPATH, "//*[@data-value='119']"))
)
target_option.click()

补充说明

  • 优先使用element_to_be_clickable而非visibility_of_element_located,确保元素处于可交互状态
  • 如果data-value定位失效,可改用文本精准定位:(By.XPATH, "//*[text()='Wayne RESA (82)']")
  • 无需使用ActionChains的move_to_element,直接点击元素的逻辑更稳定

内容的提问来源于stack exchange,提问作者Victor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 04:08:28