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

添加--remote-debugging-port后Edge出现chrome not reachable错误求助

Edge Selenium切换配置文件启动异常解决方案

问题情况

不切换浏览器配置文件时测试可正常运行,添加Edge配置项切换到指定配置文件后,驱动启动抛出devtoolsactiveport file doesn't exist edge selenium错误。添加--remote-debugging-port=14837参数后,又出现chrome not reachable错误。

代码示例

EdgeOptions edgeoptions = new EdgeOptions();
edgeoptions.addArguments("--remote-debugging-port=14837");
edgeoptions.addArguments("--start-maximized");
edgeoptions.addArguments("user-data-dir=C:\\Users\\jagadish\\AppData\\Local\\Microsoft\\Edge\\User Data");
edgeoptions.addArguments("profile-directory=Profile 2");
WebDriver driver = new EdgeDriver(edgeoptions);

错误信息

Microsoft Edge WebDriver was started successfully.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: Microsoft Edge failed to start: exited normally.
  (chrome not reachable)
  (The process started from msedge location C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe is no longer running, so msedgedriver is assuming that msedge has crashed.) 
Host info: host: 'JAGADISH-LAPTOP', ip: '192.168.1.105'
Build info: version: '4.7.2', revision: '4d4020c3b7'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1'
Driver info: org.openqa.selenium.edge.EdgeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: MicrosoftEdge, ms:edgeOptions: {args: [--remote-debugging-port=14837, --start-maximized, user-data-dir=C:\Users\jaga..., profile-directory=Profile 2], extensions: []}}], desiredCapabilities=Capabilities {browserName: MicrosoftEdge, ms:edgeOptions: {args: [--remote-debugging-port=14837, --start-maximized, user-data-dir=C:\Users\jaga..., profile-directory=Profile 2], extensions: []}}}] 

解决步骤

  • 清理Edge进程:打开任务管理器,结束所有msedge.exe和msedgedriver.exe进程,释放端口和配置文件锁。
  • 更换调试端口:将--remote-debugging-port更换为不常用端口(如9222),避免端口冲突:
    edgeoptions.addArguments("--remote-debugging-port=9222");
    
  • 检查权限与路径:确认user-data-dir路径完整且有读写权限,避免路径被截断或无权限访问。
  • 排除配置文件占用:确保指定的Profile 2未被其他Edge实例占用,关闭所有使用该配置的浏览器窗口。
  • 添加兼容参数:加入--no-sandbox和--disable-dev-shm-usage参数,解决系统资源限制问题:
    edgeoptions.addArguments("--no-sandbox");
    edgeoptions.addArguments("--disable-dev-shm-usage");
    
  • 匹配版本:确保msedgedriver版本与本地Edge浏览器版本完全一致,版本不匹配会引发启动异常。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 08:45:15