使用Microsoft Edge Driver自动化时遇SessionNotCreatedException问题求助
Edge Driver自动化SessionNotCreatedException问题排查与解决
错误信息
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Host info: host: 'YOGESH', ip: '192.168.1.7' Build info: version: '4.10.0', revision: 'c14d967899' System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.7 Driver info: org.openqa.selenium.edge.EdgeDrivertext
控制台错误截图

可能原因及解决办法
浏览器与驱动版本不匹配:
- 查看Edge浏览器版本:打开Edge→右上角三个点→帮助和反馈→关于Microsoft Edge,获取版本号
- 下载对应版本的Edge Driver,确保版本号完全一致(区分32/64位)
- 替换项目或系统路径中的旧驱动,保证代码指向正确的驱动文件
驱动路径配置错误:
- 将Edge Driver所在路径添加到系统
PATH环境变量,重启IDE后重试 - 或在代码中直接指定驱动路径,示例:
System.setProperty("webdriver.edge.driver", "C:\\your-path\\msedgedriver.exe"); EdgeDriver driver = new EdgeDriver();
- 将Edge Driver所在路径添加到系统
权限不足:
- 以管理员身份运行IDE或终端,避免浏览器启动被权限限制
- 临时关闭杀毒软件/防火墙,排除拦截可能
Selenium与驱动兼容性问题:
- 当前Selenium版本为4.10.0,尝试升级到最新稳定版
- 确保驱动版本与Selenium版本适配
进程残留:
- 打开任务管理器,结束所有
msedge.exe和msedgedriver.exe进程,重新运行脚本
- 打开任务管理器,结束所有
内容的提问来源于stack exchange,提问作者Yogesh Pawar
相关产品推荐
相关产品推荐

