连接到 LAN 时无法运行 selenium 脚本

2024-02-26

连接到 LAN 时无法运行 selenium 脚本,但连接到 WIFI 时它可以正常工作。我将所有代理设置保持不变。 下面是代码:

    String exePath = "/usr/local/bin/chromedriver";
    System.setProperty("webdriver.chrome.driver", exePath);
    WebDriver driver = new ChromeDriver();
    driver.get("https://www.google.com");

操作系统:Mac 10.11.6 硒:2.53 还尝试过3.8.1 Chrome 驱动程序:2.33.2 铬:V60。 日食氧气。

得到下面提到的错误消息:

Starting ChromeDriver 2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2) on port 21777
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception
from disconnected: unable to connect to renderer
(Session info: chrome=60.0.3112.113)
(Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.65 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: '01hw382197', ip: '172.25.155.171', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '9.0.4'
Driver info: org.openqa.selenium.chrome.ChromeDriver

该错误说明了一切:

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception
from disconnected: unable to connect to renderer
(Session info: chrome=60.0.3112.113)
(Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.65 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'

主要原因是您使用的二进制文件是不相容 as :

  • 您正在使用Chrome驱动程序 v2.33 of (2017-10-03)
  • Your Chrome浏览器版本是60.x
  • Your 硒客户端版本是2.53.1 of 时间: '2016-06-30 17:32:46'

所以有一个差不多的时间差2 years之间的释放硒客户端 v2.53.1 and Chrome驱动程序v2.33

Solution

  • 升级你的硒客户端到最近硒 v3.9.1 level.
  • 升级你的Chrome驱动程序到最近Chrome 驱动程序=2.35 level.
  • 根据发行说明Chrome 驱动程序=2.35 https://chromedriver.storage.googleapis.com/2.35/notes.txt升级你的Chrome浏览器 to 铬 v62-64 levels.
  • 如果你的基地Chrome浏览器版本太旧卸载Chrome浏览器通过雷沃卸载程序 https://www.revouninstaller.com/revo_uninstaller_free_download.html并安装最近发布的 GA 版本Chrome浏览器
  • Run CCleaner https://www.ccleaner.com/ccleaner工具定期清除执行之前和之后的所有操作系统杂务测试套件
  • 执行你的Tests

Update

正如你提到的,你是连接到 LAN 时无法运行脚本,但连接到 WIFI 时可以正常运行您需要确保以下几点:

  • 使用的端口网络驱动程序变种(Gecko驱动程序 / Chrome驱动程序 / IE驱动服务器)不被 LAN 上的任何其他软件/服务使用。
  • LAN 管理员不会出于特定目的而阻止端口(端口范围)。
  • 防火墙已禁用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

连接到 LAN 时无法运行 selenium 脚本 的相关文章

随机推荐