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

Robot Framework列表选择报错ElementNotInteractableException求助

解决Robot Framework中Select2下拉框ElementNotInteractableException问题

问题原因

  1. 页面使用的是Select2自定义下拉组件,原生<select>标签被select2-offscreen类隐藏,直接操作原生<option>元素会触发ElementNotInteractableException——隐藏元素无法被交互。
  2. 目标选项le chateau dans le ciel带有hideSelect2Option类,默认处于隐藏状态,无法通过直接点击原生option选中。

解决方案

需要模拟用户操作Select2组件的真实流程:点击触发按钮展开下拉框 → 搜索目标选项(使其显示) → 点击Select2生成的自定义选项元素。

Robot Framework代码示例

# 点击Select2触发按钮,展开下拉框
Wait Until Keyword Succeeds    2 minutes    2s    Click Element    xpath=//div[@id="s2id_IDTBLABLA"]/a[@class="select2-choice"]

# 等待Select2搜索框加载并输入目标选项文本
Wait Until Keyword Succeeds    2 minutes    2s    Input Text    xpath=//input[@class="select2-input"]    le chateau dans le ciel

# 等待目标选项显示并点击
Wait Until Keyword Succeeds    2 minutes    2s    Click Element    xpath=//div[@class="select2-result-label" and contains(text(),'le chateau dans le ciel')]

注意事项

  • 核对元素定位符:确保div[@id="s2id_IDTBLABLA"]对应你的Select2容器ID(原生select的ID是IDTBLABLA,Select2容器ID通常为s2id_+原生select ID)。
  • 如果搜索框不可输入,可能是Select2的模式问题,可尝试直接点击展开后的选项(若选项未被完全隐藏),调整xpath为xpath=//div[contains(@class,"select2-results")]//div[contains(text(),'le chateau dans le ciel')]。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 18:45:10