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

Edge IE模式下Selenium(IE Driver)弹窗触发栈溢出错误,需在Edge内打开弹窗

解决IE Driver启动Edge IE模式时弹窗跳转至IE并报错的问题
  • 配置Edge IE模式弹窗权限
    打开Edge浏览器,进入「设置和更多」→「设置」→「默认浏览器」,找到「Internet Explorer模式」相关设置,勾选允许网站在Internet Explorer模式下打开弹出窗口,确保弹窗不会被强制导向独立IE进程。

  • 调整IE Driver初始化参数
    初始化IE Driver时,必须指定Edge的IE模式绑定参数,强制驱动关联Edge进程而非独立IE:

    DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
    // 启用Edge Chromium的IE模式
    capabilities.setCapability("ie.edgechromium", true);
    // 指定Edge浏览器安装路径(根据实际路径调整)
    capabilities.setCapability("ie.edgepath", "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");
    // 关闭弹窗拦截,允许在当前上下文打开弹窗
    capabilities.setCapability("ie.popupBlocker", false);
    // 确保每次会话无残留状态
    capabilities.setCapability("ie.ensureCleanSession", true);
    
    WebDriver driver = new InternetExplorerDriver(capabilities);
    
  • 替换JavascriptExecutor点击方式
    避免使用基础JS点击,改用更贴近用户行为的触发方式,或直接用WebElement原生点击:

    • 原生点击(优先尝试):
      WebElement targetLink = driver.findElement(By.xpath("目标链接的XPath"));
      targetLink.click();
      
    • 增强版JS点击(原生点击失效时使用):
      ((JavascriptExecutor) driver).executeScript(
          "arguments[0].dispatchEvent(new MouseEvent('click', {bubbles: true, cancelable: true, view: window}));",
          targetLink
      );
      

    这类点击会保留当前Edge IE模式的上下文,避免弹窗跳转至独立IE进程。

  • 清理残留IE进程
    运行测试前,打开任务管理器结束所有iexplorer.exe进程,防止残留进程劫持弹窗请求导致报错。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 23:38:17