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
相关产品推荐
相关产品推荐

