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

Selenium无法定位已存在的下拉框元素 定位报错求助

Selenium下拉框元素定位失败问题

我已尝试Stack Overflow上的所有相关解决方案,但问题仍未解决。
当前需要实现的操作是从下拉框中选择指定选项,下拉框样式可查看截图:点击查看下拉框

下拉框对应HTML结构

<td ct="GLC" lsdata="{1:'STANDARD'}" id="WD18" class="lsContainerCell lsGLCTopVAlign lsContainerCellVAlign--top  urLayoutDefault--grid" valign="TOP" align="left" style="white-space:normal;">
  <span id="WD19-r" class="lsField lsField--standalone lsField--explicitwidth lsField--hasellipsis lsField--hashelp lsField--list lsField--focus lsField--interactiontarget" aria-live="assertive" style="">
    <input id="WD19" ct="CB" lsdata="{2:'WD1A',3:'10',4:'2021\x2f2022',27:'WD17'}" lsevents="{Select:[{ResponseData:'delta',EnqueueCardinality:'single'},{}]}" type="text" autocomplete="off" tabindex="0" ti="0" class="lsField__input" readonly="" value="2021/2022" role="combobox" aria-haspopup="listbox" aria-readonly="false" aria-controls="WD1A" aria-expanded="false" aria-autocomplete="list" style="width:150px;" title="">
    <span id="WD19-btn" class="lsField__help" tabindex="-1" ti="-1" aria-hidden="true" role="button"></span>
  </span>
</td>

已尝试方案与报错信息

  • 先后尝试By.ID、By.XPATH两类定位方式,最后一次使用的定位语句如下:
driver.find_element(By.XPATH, "/html/body/table/tbody/tr/td/div/div[1]/span/span[1]/table/tbody/tr[2]/td/table/tbody/tr[1]/td[2]")
  • 运行后反复触发相同报错:
Message: no such element: Unable to locate element

在此先行感谢各位提供的解答思路。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.28 01:18:49