Reputation: 3596
I 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.
Upvotes: 5
Views: 20383
Reputation: 17553
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
Upvotes: 6
Reputation: 414
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')
Upvotes: 0
Reputation: 193108
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)
Upvotes: 1