1

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$
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
riccardo
  • 13
  • 1
  • 4
  • Do you use selenium inside the `while` loop? – Greg Burghardt Aug 30 '19 at 16:51
  • yes, inside while a call a function that call another function that use selenium – riccardo Aug 30 '19 at 16:56
  • How does initializing webdriver.Chrome below the while loop slow things down? The initialization time is the same above or below the loop. Maybe it is slowing down after the loop executes because the Python execution environment is bogged down after having run for a long time? – Greg Burghardt Aug 30 '19 at 17:17
  • i mean that as soon as i exit the while i need to be really fast, if i initialize webdriver below while i lose like 3-4 second i think, also because im running this code inside a really poor pc. instead if i intialize at first it is only needed to load the page given to it – riccardo Aug 30 '19 at 17:32
  • 1
    You have a thing that runs for "hours" and then you are worried about 3-4 seconds after it finishes? I think you are trying to solve the wrong performance problem here. – Greg Burghardt Aug 30 '19 at 17:34
  • Don't worry about that, maybe you're right (most likely) just please, if you have any idea, help me to solve my problem. thanks! – riccardo Aug 30 '19 at 17:40
  • Just trying to understand more what your constraints are. Why is that 3-4 seconds delay so critical? – Greg Burghardt Aug 30 '19 at 18:54
  • @GregBurghardt Observe the Chrome version in the stack trace being converted into an `ip_address`. Without the knowledge of the step `#do thing that require hours` virtually it's impossible. – undetected Selenium Aug 30 '19 at 21:38

2 Answers2

5

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:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    Should have known better. Any time you see a wonky error that makes absolutely no sense, check the chrome and chrome driver versions. – Greg Burghardt Aug 31 '19 at 00:17
  • In my case all was working fine until that error. After read this I checked active processes with `ps -aux` and I found hundred google chrome processes. I think it's not reachable because of that. LoL – V-cash May 22 '21 at 08:05
0

In my case I'm using a server to launch the app. This was due I had a lot of google-chrome active processes running so chrome was overwhelmed.

You can check this with ps -aux command and see google processes.

In my case as I didn't use try driver.get(url) , except: driver.close() all those failed attemtps keeped opened in my server.

I killed them all with killall usernamehere

then it worked again.

Hope it works for you too

V-cash
  • 330
  • 3
  • 14