Selenium自动化chrome驱动版本匹配但是调用浏览器失败:Only local connections are allowed. 问题解决

简介: Selenium自动化chrome驱动版本匹配但是调用浏览器失败:Only local connections are allowed. 问题解决

第一次发现这种情况,驱动版本完全对的上,但是调用 chrome 就提示 Only local connections are allowed. 然后浏览器调用失败报错。

Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver s
afe.
ChromeDriver was started successfully.

解决方法:

调用 chrome 驱动的时候加个参数 --whitelisted-ips="",值为空就是把所有调入来源都加入白名单。

ips 的全称是 intrusion prevention system,解释为入侵防御系统。

C:\Selenium2.0\driver>chromedriver_70.0.3538.97_win32.exe --whitelisted-ips=""
Starting ChromeDriver 70.0.3538.97 (d035916fe243477005bc95fe2a5778b8f20b6ae1) on port 9515
All remote connections are allowed. Use a whitelist instead!

如果是封装好的不能代码里集成,可以外部 cmd 窗口里启用驱动,后面加上这个参数,注意参数前要有个空格,注意窗口不要关,不然就失效了,可以保证启用过程中可以正常的调用 chrome。

如果每次都这么做,可以创建个快捷方式,里面写好参数,这样就每次执行个快捷方式就完事了。

4053e45804bf4773b74754f6cd76c858.png

详细报错内容展示:

老版本和新版本的报错内容存在一定差异。

6a6b1906265448c2b0f22d4335819513.png

Only local connections are allowed.
Exception in thread "AWT-EventQueue-0" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'DESKTOP-1MPSR34', ip: '10.6.255.208', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_121'
Driver info: driver.version: SeleniumDriver
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:141)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:174)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:163)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:152)
        at com.yyuap.selenium.SeleniumDriver.initDriver(SeleniumDriver.java:195)
        at com.yyuap.selenium.Debuger.init(Debuger.java:256)
        at com.yyuap.selenium.Debuger.actionPerformed(Debuger.java:124)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
        at java.awt.Component.processMouseEvent(Component.java:6533)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
        at java.awt.Component.processEvent(Component.java:6298)
        at java.awt.Container.processEvent(Container.java:2236)
        at java.awt.Component.dispatchEventImpl(Component.java:4889)
        at java.awt.Container.dispatchEventImpl(Container.java:2294)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
        at java.awt.Container.dispatchEventImpl(Container.java:2280)
        at java.awt.Window.dispatchEventImpl(Window.java:2746)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:709)
        at java.awt.EventQueue$3.run(EventQueue.java:703)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
        at java.awt.EventQueue$4.run(EventQueue.java:731)
        at java.awt.EventQueue$4.run(EventQueue.java:729)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
        at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76)
        at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:173)
        at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:185)
        at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
        at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
        ... 45 more
目录
相关文章
|
2月前
|
人工智能 自然语言处理 测试技术
从人工到AI驱动:天猫测试全流程自动化变革实践
天猫技术质量团队探索AI在测试全流程的落地应用,覆盖需求解析、用例生成、数据构造、执行验证等核心环节。通过AI+自然语言驱动,实现测试自动化、可溯化与可管理化,在用例生成、数据构造和执行校验中显著提效,推动测试体系从人工迈向AI全流程自动化,提升效率40%以上,用例覆盖超70%,并构建行业级知识资产沉淀平台。
从人工到AI驱动:天猫测试全流程自动化变革实践
|
7月前
|
数据采集 机器学习/深度学习 人工智能
运维人的“福音”?AI 驱动的自动化网络监控到底香不香!
运维人的“福音”?AI 驱动的自动化网络监控到底香不香!
781 0
|
3月前
|
人工智能 安全 Devops
AI 驱动的 DevOps:通过智能命令执行实现基础设施自动化
本文探讨了如何利用能够根据自然语言提示执行命令、管理基础设施和自动部署的 AI 技术,来革新 DevOps 流程。通过模型上下文协议(MCP),AI 助手不仅能回答问题,还能直接操作终端、编辑文件并管理开发环境,从而简化复杂的 DevOps 任务,提高效率并降低错误率。
346 3
|
4月前
|
人工智能 运维 安全
运维老哥的救星?AI 驱动的自动化配置管理新趋势
运维老哥的救星?AI 驱动的自动化配置管理新趋势
289 11
|
4月前
|
JSON 缓存 供应链
API 接口驱动 1688 采购自动化:从商品获取到下单支付的全流程贯通
在B2B电商采购中,1688开放平台通过API实现商品筛选、比价、下单、支付及物流跟踪的全流程自动化,大幅提升采购效率,降低人工成本与错误率。企业可无缝对接ERP系统,实现数据驱动决策,显著优化采购周期、成本与风险管控,助力数字化转型。
|
运维 Prometheus 监控
如何在测试环境中保持操作系统、浏览器版本和服务器配置的稳定性和一致性?
如何在测试环境中保持操作系统、浏览器版本和服务器配置的稳定性和一致性?
|
Web App开发 JSON 安全
Chrome浏览器的跨域问题
【10月更文挑战第6天】
2304 123
|
11月前
|
人工智能 自然语言处理 语音技术
FilmAgent:多智能体共同协作制作电影,哈工大联合清华推出 AI 驱动的自动化电影制作工具
FilmAgent 是由哈工大与清华联合推出的AI电影自动化制作工具,通过多智能体协作实现从剧本生成到虚拟拍摄的全流程自动化。
2863 13
FilmAgent:多智能体共同协作制作电影,哈工大联合清华推出 AI 驱动的自动化电影制作工具
|
11月前
|
Web App开发 人工智能 JSON
AutoMouser:AI Chrome扩展程序,实时跟踪用户的浏览器操作,自动生成自动化操作脚本
AutoMouser是一款Chrome扩展程序,能够实时跟踪用户交互行为,并基于OpenAI的GPT模型自动生成Selenium测试代码,简化自动化测试流程。
772 17
AutoMouser:AI Chrome扩展程序,实时跟踪用户的浏览器操作,自动生成自动化操作脚本
|
12月前
|
数据采集 人工智能 自然语言处理
Midscene.js:AI 驱动的 UI 自动化测试框架,支持自然语言交互,生成可视化报告
Midscene.js 是一款基于 AI 技术的 UI 自动化测试框架,通过自然语言交互简化测试流程,支持动作执行、数据查询和页面断言,提供可视化报告,适用于多种应用场景。
2970 1
Midscene.js:AI 驱动的 UI 自动化测试框架,支持自然语言交互,生成可视化报告