Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
732 views
in Technique[技术] by (71.8m points)

python - WebDriverException: Message: chrome not reachable after long time

This is the code:

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

I need to open first selenium and then make things that require hours because when i open selenium i need to be ready and speed. If put driver = webdriver.Chrome() below the while, it would slow everything down i don't know if it is relevant but i run this code with nohup command.

Traceback:

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$
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Initially I had asked myself the same questions as @GregBurghardt had been asking in the comments till I analyzed the detailed error stack trace.

Yes, there is somehting amazing happening in those steps marked as #do thing that require hours. Hence, instaed of showing Chrome browser version as chrome=76.0, chrome=75.0 or chrome=74.0 it shows:

(Session info: chrome=192.168.0.0)

which is pretty much surprising.

It would be almost impossible to analyze the issue until and unless you update us why and how the Chrome version gets changed to such value.


Having said that, possibly your main issue is the incompatibility between the version of the binaries you are using.

  • You are using chromedriver=2.36
  • Release Notes of chromedriver=2.36 clearly mentions the following :

Supports Chrome v63-65

  • Presumably you are using the latest chrome= 76.0
  • Release Notes of ChromeDriver v76.0 clearly mentions the following :

Supports Chrome version 76

  • Your Selenium Client version is unknown to us.

So there is a clear mismatch between the ChromeDriver v2.36 and the Chrome Browser v76.0


Solution

Ensure that:

  • Selenium is upgraded to current levels Version 3.141.59.
  • ChromeDriver is updated to current ChromeDriver v76.0 level.
  • Chrome is updated to current Chrome Version 76.0 level. (as per ChromeDriver v76.0 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test as non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

References:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...