7

I am facing the issue with python selenium I entered the code below, it worked well few minutes ago, but now it doesn't work saying chrome not reachable Please help!

from selenium import webdriver
driver = webdriver.Chrome('/Users/Danny/Downloads/chromedriver_win32/chromedriver')
driver.get('https://google.com')

results

---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
<ipython-input-36-6bcc3a6d3d05> in <module>()
----> 1 driver.get('https://google.com')

~\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in get(self, url)
    322         Loads a web page in the current browser session.
    323         """
--> 324         self.execute(Command.GET, {'url': url})
    325 
    326     @property

~\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
    310         response = self.command_executor.execute(driver_command, params)
    311         if response:
--> 312             self.error_handler.check_response(response)
    313             response['value'] = self._unwrap_value(
    314                 response.get('value', None))

~\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
    240                 alert_text = value['alert'].get('text')
    241             raise exception_class(message, screen, stacktrace, alert_text)
--> 242         raise exception_class(message, screen, stacktrace)
    243 
    244     def _value_or_default(self, obj, key, default):

WebDriverException: Message: chrome not reachable
  (Session info: chrome=64.0.3282.140)
  (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.16299 x86_64)

Edit

It does work when I try this code, but I don't know why it suddenly works Can someone explain this code?

driver=webdriver.Chrome(executable_path="C:/Users\Danny\Downloads\chromedriver_win32\chromedriver.exe")

for i in range(1,10):
driver.get('https://google.com')
danny
  • 111
  • 3
  • 8
  • Possible duplicate of [Chrome not reachable Selenium WebDriver error](https://stackoverflow.com/questions/45688020/chrome-not-reachable-selenium-webdriver-error) – Mike Scotty Feb 12 '18 at 08:34
  • I've recently had the same problem. My problem was that I didn't have chrome(automated) one open. So I've opened it an ran the code and it worked. – haneulkim Apr 10 '19 at 19:35

3 Answers3

4

The error you are seeing gives us some hint as follows :

WebDriverException                        Traceback (most recent call last)
<ipython-input-36-6bcc3a6d3d05> in <module>()
----> 1 driver.get('https://google.com')

Here are some observations and remedies :

  • First of all, I would like you to look back at the exact absolute path of the ChromeDriver binary and my guess is instead of :

    /Users/Users/Downloads/chromedriver_win32/chromedriver
    

    It should have been :

    /Users/Downloads/chromedriver_win32/chromedriver
    
  • Moreover, a better way to pass the location of the ChromeDriver binary would be to pass the argument executable_path along as well, so the line would be :

    driver = webdriver.Chrome(executable_path=r'/Users/Users/Downloads/chromedriver_win32/chromedriver')
    
  • Finally, whenever you invoke get() method to open an URL try to pass the Fully Qualified Domain Name (FQDN) as follows :

    driver.get('https://www.google.co.in')
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
1

Use this.

from selenium import webdriver
path=r"/Users/Users/Downloads/chromedriver_win32/chromedriver"
driver=webdriver.Chrome(path)
driver.get("https://google.com")

That r in the path stands for "raw" and it might fix your problem.

Rajat Singh
  • 155
  • 1
  • 1
  • 11
  • 2
    Thank you for your answer, but it doesn't work...it shows same error :( When i run 'driver' code, it pops up new Chrome tab saying that data:, – danny Feb 20 '18 at 14:14
1

For what it's worth, I have found that simply restarting my development machine solves this problem for me. It occasionally crops up with no particular explanation, and resolves with a reboot.

DHZ
  • 11
  • 1