selenium-server-4.7.2 报错 Only local connections are allowed. 怎么处理?
报错信息
Starting ChromeDriver 108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016})
on port 22060
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver s
afe.
ChromeDriver was started successfully.
网上很多网友说是因为版本不兼容的问题,但是我的版本是没有问题的
我只是将 selenium-server-4.7.1.jar 升级至 selenium-server-4.7.2.jar 出现的问题,果然是配置问题
WebDriver服务启动后提示 Only local connections are allowed.
这个是因为Chrome默认不允许跨机器调试,只需要给启动命令加上白名单即可。
If you use ChromeDriver locally/directly from code, just insert lines below before ChromeDriver init
System.setProperty("webdriver.chrome.whitelistedIps", "");
If you use it remotely (eg. selenium hub/grid) you need to set system property when node starts, like in command:
java -Dwebdriver.chrome.whitelistedIps= testClass etc...
or docker by passing JAVA_OPTS
env
chrome:
image: selenium/node-chrome:3.141.59
container_name: chrome
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
- JAVA_OPTS=-Dwebdriver.chrome.whitelistedIps=
也可以参考 Selenium 远程部署采坑记
同时 System.setProperty("webdriver.chrome.silentOutput", "true");
参数也失效了,目前还没找到解决办法...
官方升级说明中提示了改变了日志方式了
v4.7.2
======
* Grid: Support file downloads on the node (#11277)
* Change chromium service names from whitelisted to allowed (#11409)
* Avoid closing CDP connection in browser implementation since that logic now sits in RemoteWebDriver (Fixes #11401)
* Fix bug where failing Selenium Manager method results in wrong error
* Allow changing chromium driver log timestamp formatting
* Allow ignoring chromedriver build checks using service builders
* Add support for appendLog to msedgedriver service
* Fix msedgedriver log level logic
* Allow setting chromedriver log level from system properties
* Fix chromedriver log level logic
* Remove deprecated Firefox capabilities
* Removing a few bits more of the magic that moves JWP to W3C
* Removing deprecated SUPPORTS_ALERTS and SUPPORTS_SQL_DATABASE caps
* Removing deprecated OVERLAPPING_CHECK_DISABLED cap
* Removing deprecated LOGGING_PREFS cap
* Removing deprecated HAS_TOUCHSCREEN cap
* Removing deprecated HAS_NATIVE_EVENTS cap
* Removing deprecated ENABLE_PROFILING_CAPABILITY cap
* Removing deprecated ACCEPT_SSL_CERTS cap