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
目录
相关文章
|
3月前
|
Web App开发 人工智能 自然语言处理
Playwright MCP浏览器自动化指南
本文教你如何通过Playwright MCP让AI直接操作浏览器,自动运行和调试代码,无需手动切换界面。只需简单配置,即可用自然语言指挥AI完成页面操作、问题排查与自主修复,真正实现自动化高效开发。
|
3月前
|
人工智能 自然语言处理 监控
Browser Use:打造你的浏览器自动化助手
你是否曾希望用简单的一句话就能让浏览器自动填表、抓数据或做测试?Browser Use 让这成为现实。它结合了语言模型的智能和传统自动化的稳定,能听懂自然语言指令,自己规划步骤,还能应对网页变动和错误。无论是开发者还是普通用户,都能用它高效完成日常操作,省时省力。安装简单,写行指令就能马上体验。
|
2月前
|
数据采集 人工智能 自然语言处理
Playwright MCP 浏览器自动化框架全面解析
Playwright MCP是微软推出的开源项目,结合Playwright与MCP协议,让AI通过结构化数据直接操作浏览器。告别传统视觉识别,实现高效、精准的网页自动化,广泛应用于测试、爬虫、办公自动化等场景,大幅提升效率与可靠性。
|
3月前
|
人工智能 自然语言处理 监控
Playwright MCP浏览器自动化全攻略
Playwright MCP让AI通过自然语言操控浏览器,无需编程即可实现网页自动化。支持智能元素识别、多浏览器操作与动态交互,广泛应用于搜索、数据抓取、自动发布等场景,大幅提升效率,降低技术门槛,是浏览器自动化的新范式。
|
2月前
|
Web App开发 人工智能 JavaScript
入门指南:使用 Playwright MCP Server 为你的 AI Agent 赋予浏览器自动化能力
借助Playwright MCP Server,AI助手可实现网页自动操作:填表、抓数据、执行重复任务。通过MCP协议连接AI与浏览器,让AI从“能说”变为“会做”。支持主流浏览器,配置简单,助力打造智能数字助手。
|
3月前
|
人工智能 自然语言处理 监控
Browser Use 浏览器自动化 Agent:让浏览器自动为你工作
Browser Use是一款创新浏览器自动化框架,结合LLM智能与自动化技术,能理解自然语言指令,自主操作浏览器完成任务,如数据抓取、表单填写、自动化测试等。具备智能决策、自适应处理、自然语言交互和自我修正能力,简化复杂任务,提升效率。
|
5月前
|
Web App开发 开发框架 .NET
Playwright 自动化测试系列(6)| 第三阶段:测试框架集成​指南:参数化测试 + 多浏览器并行执行
Pytest 与 Playwright 集成可提升自动化测试效率,支持参数化测试、多浏览器并行执行及统一报告生成。通过数据驱动、Fixture 管理和并行优化,显著增强测试覆盖率与执行速度,适用于复杂 Web 应用测试场景。
|
7月前
|
数据采集 前端开发 JavaScript
深挖navigator.webdriver浏览器自动化检测的底层分析
本文详细讲解了如何通过技术手段破解浏览器 `navigator.webdriver` 检测,结合爬虫代理、多线程等策略,在豆瓣图书页面批量采集数据。具体包括:隐藏 Selenium 特征、配置代理突破 IP 限制、设置伪装用户、利用多线程提升效率。文章面向初学者,提供分步教程与示例代码,同时设有「陷阱警告」帮助规避常见问题。目标是从底层实现反检测,高效采集图书评分、简介、作者等信息,适合具备 Python 和 Selenium 基础的读者实践学习。
293 12
深挖navigator.webdriver浏览器自动化检测的底层分析
|
8月前
|
数据采集 JavaScript 前端开发
浏览器自动化检测对抗:修改navigator.webdriver属性的底层实现
本文介绍了如何构建一个反检测爬虫以爬取Amazon商品信息。通过使用`undetected-chromedriver`规避自动化检测,修改`navigator.webdriver`属性隐藏痕迹,并结合代理、Cookie和User-Agent技术,实现稳定的数据采集。代码包含浏览器配置、无痕设置、关键词搜索及数据提取等功能,同时提供常见问题解决方法,助你高效应对反爬策略。
719 1