WebDriverException:消息:长时间后无法访问 chrome

1 python selenium google-chrome selenium-chromedriver selenium-webdriver

这是代码:

driver = webdriver.Chrome()
while True:
   #do thing that require hours
   #then i use selenium once
driver.get(link)
Run Code Online (Sandbox Code Playgroud)

我需要先打开硒,然后制作需要几个小时的东西,因为当我打开硒时,我需要做好准备并加快速度。如果放在driver = webdriver.Chrome()while 之下,它会减慢一切,我不知道它是否相关,但我用nohup命令运行此代码。

追溯:

Traceback (most recent call last):
  File "Scraper.py", line 84, in <module>
    main()
  File "Scraper.py", line 74, in main
    waitForSomething()
  File "Scraper.py", line 54, in waitForSomething
    fillForm(str(link)[2:-2])
  File "Scraper.py", line 30, in fillForm
    driver.get(link)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
    self.execute(Command.GET, {'url': url})
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_resp$
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
  (Session info: chrome=192.168.0.0)
  (Driver info: chromedriver=2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752),platform=Linux 4.9.0-9-amd64 x$
Run Code Online (Sandbox Code Playgroud)

Deb*_*anB 5

最初,我问自己与 @GregBurghardt 在评论中提出的问题相同的问题,直到我分析了详细的错误堆栈跟踪。

是的,在标记为 的步骤中发生了一些令人惊奇的事情#do thing that require hours。因此,不再将Chrome浏览器版本显示为chrome=76.0chrome=75.0或者chrome=74.0显示:

(Session info: chrome=192.168.0.0)
Run Code Online (Sandbox Code Playgroud)

这非常令人惊讶。

除非您向我们更新Chrome版本更改为这样的值的原因和方式,否则几乎不可能分析该问题。


话虽如此,您的主要问题可能是您正在使用的二进制文件版本之间的不兼容。

  • 您正在使用chromedriver=2.36
  • chromedriver=2.36的发行说明明确提到了以下内容:

支持Chrome v63-65

  • 大概您使用的是最新的chrome= 76.0
  • ChromeDriver v76.0的发行说明明确提到了以下内容:

支持Chrome 版本 76

  • 我们不知道您的Selenium 客户端版本。

因此ChromeDriver v2.36Chrome 浏览器 v76.0之间存在明显的不匹配


解决方案

确保这件事:

  • Selenium升级到当前级别Version 3.141.59
  • ChromeDriver已更新至当前ChromeDriver v76.0级别。
  • Chrome已更新至当前Chrome 版本 76.0级别。(根据ChromeDriver v76.0 发行说明
  • 通过IDE清理项目工作区并仅使用所需的依赖项重建项目。
  • 如果您的基本Web 客户端版本太旧,请将其卸载并安装最新的 GA 和发布版本的Web 客户端
  • 重新启动系统
  • @Test非 root用户身份执行。
  • driver.quit()始终在方法内调用tearDown(){}以优雅地关闭和销毁WebDriverWeb Client实例。

参考:


归档时间:

查看次数:

9614 次

最近记录:

4 年,3 月 前