5

enter image description hereI am trying to automate my web application using the python and selenium, I am facing the below issue.

Environment - Mac/Python/Selenium IDE - PyCharm

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Please help me resolve this issue.

acikojevic
  • 915
  • 1
  • 7
  • 16
Bhupendra Singh Rautela
  • 3,406
  • 6
  • 21
  • 25
  • 3
    Possible duplicate of [Error message: "'chromedriver' executable needs to be available in the path"](https://stackoverflow.com/questions/29858752/error-message-chromedriver-executable-needs-to-be-available-in-the-path) – Saurabh Gaur Sep 06 '17 at 12:28
  • Please read why [a screenshot of code is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Paste the code and properly format it instead. – JeffC Sep 06 '17 at 13:05

3 Answers3

6

Yes. because you haven't pass the Chrome binary which required by Selenium to drive your Chrome browser.

You need to download binary as per your OS from below URL :-

https://chromedriver.storage.googleapis.com/index.html?path=2.32/

Use below code :-

import os
from selenium import webdriver

chromedriver = "/Users/adam/Downloads/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.get("http://stackoverflow.com")

Change the path of chromedriver in above code

OR

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities.CHROME
cap = {'binary_location': /Users/adam/Downloads/chromedriver"}
driver = webdriver.Chrome(desired_capabilities=cap, executable_path="/Users/adam/Downloads/chromedriver")
driver.get('http://google.com/')

OR

Alternatively you can use a direct path to the chromedriver like this:

 driver = webdriver.Chrome('/path/to/chromedriver')

Source:

Running Selenium WebDriver python bindings in chrome

halfer
  • 19,824
  • 17
  • 99
  • 186
Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
1

You need to download the chromedriver binary from ChromeDriver Download page and place it anywhere within your system. While you initiate the WebDriver instance you need to mention the absolute path of the ChromeDriver binary.

On my Windows 8 system the following code block works perfect:

from selenium import webdriver

driver = webdriver.Chrome(executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

At firsts you need to download chrome driver from https://sites.google.com/a/chromium.org/chromedriver/downloads then unarchive it. then add this file to params of enviroments. And then write driver = webdriver.Chrome('C:\YourPathofChromeDriver\chromedriver.exe')

Avo Asatryan
  • 404
  • 8
  • 21