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

Edge IE模式下Python用IEDriverServer 4.8操作Select控件报错求解决

Edge IE模式下Selenium操作下拉框报错求助

错误信息

"Cannot click on option element. Executing JavaScript click function returned an unexpected error, but no error could be returned from Internet Explorer's JavaScript engine"

相关代码

调用方法

def my_select(self, text):
    self.app.select_from_drop_down('//select[@class="gender"]', text)

被调用的下拉选择方法

def select_from_drop_down(self, selector, text):
    wd = self.wd
    if text is not None:
        Select(wd.find_element(By.XPATH, selector)).select_by_visible_text(text)

测试代码

def test_select_male(app):
    app.people_page.open_page()
    app.people_page.my_select('Male')

对应的DOM结构

<select class="gender">
    <option></option>
    <option name="MALE">Male</option>
    <option name="FEMALE">Female</option>
</select>

背景说明

这是Selenium的已知未修复Bug,已有开发者给出Java版本的绕过方案,但我尝试用Python编写的绕过代码未成功。

尝试的绕过代码

def select_from_drop_down_menu(self):
    btn = wd.find_element(By.XPATH, '//select[@name="MALE"]').click()
    wd.execute_script("arguments[0].click();", btn)

恳请提供可行的Python绕过方案!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.01 03:41:28