2

I am trying to use chromedriver.exe to do some web scraping / automation -- my code is below

from selenium import webdriver 
browser = webdriver.Chrome('MY_PATH')
browser.get("https://www.google.com")
browser.close()

Once I execute the "browser" variable then a blank google browser opens, but when I try to execute the .get() function this is the error I receive:

WebDriverException                        Traceback (most recent call last)
<ipython-input-36-0ba0932650bf> in <module>
----> 1 browser.get("https://www.google.com")
      2 browser.close()

~\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in get(self, url)
    331         Loads a web page in the current browser session.
    332         """
--> 333         self.execute(Command.GET, {'url': url})
    334 
    335     @property

~\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
    319         response = self.command_executor.execute(driver_command, params)
    320         if response:
--> 321             self.error_handler.check_response(response)
    322             response['value'] = self._unwrap_value(
    323                 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=85.0.4183.102)

Any thoughts / feedback / suggestions would be greatly appreciated!

Josh
  • 21
  • 2
  • Once crosscheck the ChromeDriver version and Chrome version. [Link](https://sites.google.com/a/chromium.org/chromedriver/downloads/version-selection) – Dilip Meghwal Sep 20 '20 at 05:49

4 Answers4

0

ChromeDriver and Chrome browser aren't compatible, maybe you might have the latest Chrome browser but you don't have the latest chromeDriver - here you can download it - it's ChromeDriver 86.0.4240.22

Alin Stelian
  • 861
  • 1
  • 6
  • 16
0

first of all, make sure of the followings:

  1. make sure chromedriver exist in your 'PATH' environment variables
  2. check out your chromedriver version matches the chrome version you are using
    -you can check your chrome version from help--> about Google Chrome
    • then download compatible Chromedriver version from here
Arman Karimi
  • 11
  • 1
  • 6
0

This is caused due to the wrong chrome driver to the certain chrome version you have. You can find the chromedriver here Chrome Driver Or you could let webdriver manager handle all your issues by doing

pip install webdriver-manager in command prompt

Than simply using.

from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
Arundeep Chohan
  • 9,779
  • 5
  • 15
  • 32
0

Try this

  • Remember to pass the path to the executable_path keyword argument
  • Have matching version of Chrome and Chrome Driver

from selenium import webdriver

chrome_driver_path = '/home/aahnik/Downloads/apps/chromedriver'
# path to where chrome driver executable is installed.
# make sure to have matching versions of Chrome and Chrome Driver

driver = webdriver.Chrome(executable_path=chrome_driver_path)

driver.get("https://aahnik.github.io/")

aahnik
  • 1,661
  • 1
  • 11
  • 29