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

Windows11 Edge自动化:如何关闭Remote Debugging消除IE模式提示横幅

问题:消除Microsoft Edge自动化测试中的远程调试提示横幅

在Windows 11系统上使用Selenium对Microsoft Edge浏览器进行自动化测试时,浏览器实例弹出提示横幅:'Turn off remote debugging to open this site in internet explorer mode. Otherwise, it might not work as expected'(中文翻译:关闭远程调试以在Internet Explorer模式下打开此站点。否则,它可能无法正常工作)。已查阅同类问题但未解决,求消除该横幅的方法。

使用环境

  • Windows 11
  • Microsoft Edge:105.0.1343.42
  • Selenium:3.141.59

BaseDriver.Java 代码

else if (browser.equalsIgnoreCase("edge")) {
                System.setProperty("webdriver.edge.driver",
                        FileReaderManager.getInstance().getConfigReader().getDriverPath() + "/msedgedriver.exe");
                capabilities = DesiredCapabilities.edge();
                // Creating an object of EdgeDriver
                driver = new EdgeDriver();
                driver.manage().window().maximize();

                // Deleting all the cookies
                driver.manage().deleteAllCookies();

                // Specifiying pageLoadTimeout and Implicit wait
                driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
                driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
            }

POM.XML 代码

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ChromeTest.com</groupId>
    <artifactId>ChromeTest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
    <!--    <dependency>
            <groupId>com.github.2gis.winium</groupId>
            <artifactId>winium-elements-desktop</artifactId>
            <version>0.2.0-1</version>
        </dependency> -->

        <dependency>
            <groupId>com.github.2gis.winium</groupId>
            <artifactId>winium-webdriver</artifactId>
            <version>0.1.0-1</version>
        </dependency>
        

          <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>  

    <!--     <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.0.0-beta-4</version>
        </dependency> -->
    </dependencies> 



</project>

参考截图

截图显示Microsoft Edge浏览器顶部弹出黄色提示横幅,内容为:'Turn off remote debugging to open this site in internet explorer mode. Otherwise, it might not work as expected'

解决方案

方法1:通过EdgeOptions禁用IE模式相关特性

该提示源于Edge的IE模式与Selenium启用的远程调试模式冲突。修改BaseDriver中的Edge初始化代码,添加EdgeOptions配置来禁用IE模式或相关提示:

else if (browser.equalsIgnoreCase("edge")) {
    System.setProperty("webdriver.edge.driver",
            FileReaderManager.getInstance().getConfigReader().getDriverPath() + "/msedgedriver.exe");
    
    // 初始化EdgeOptions并添加禁用配置
    EdgeOptions options = new EdgeOptions();
    // 禁用IE模式
    options.addArguments("--disable-ie-mode");
    // 关闭首次运行提示及IE集成特性
    options.addArguments("--no-first-run");
    options.addArguments("--disable-features=InternetExplorerIntegration");
    
    capabilities = DesiredCapabilities.edge();
    capabilities.setCapability(EdgeOptions.CAPABILITY, options);
    
    // 基于配置创建EdgeDriver实例
    driver = new EdgeDriver(capabilities);
    driver.manage().window().maximize();

    driver.manage().deleteAllCookies();
    driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

方法2:通过组策略禁用IE模式(企业环境适用)

若为企业部署环境,可通过本地组策略彻底禁用IE模式相关配置:

  1. 打开本地组策略编辑器(运行gpedit.msc)
  2. 导航至计算机配置 > 管理模板 > Microsoft Edge
  3. 找到配置Internet Explorer模式选项,设置为「已禁用」
  4. 重启Edge浏览器后生效

方法3:匹配Edge驱动与浏览器版本,升级Selenium

确保msedgedriver.exe版本与Edge浏览器版本完全一致(从微软官方渠道下载对应版本)。同时可考虑升级Selenium至3.x系列最新版或4.x系列,新版本对Edge浏览器的兼容性更好,能减少此类冲突问题。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 11:10:23