Getting Chrome to launch via Selenium

haran kumar picture haran kumar · Jul 3, 2013 · Viewed 56.6k times · Source

Hi all I'm very new to this and am having issues getting an instance of a Chrome browser from selenium in python. I'm using Windows 8. I have downloaded the chromedriver binary and added it to my path but I get the following error in Python:

selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.   

This error occurs for the following line:

driver = webdriver.Chrome(executable_path='path\to\chromedriver_win32_2.0')  

Any help is greatly appreciated. Thank you.

Answer

Yi Zeng picture Yi Zeng · Jul 4, 2013

Two ways to set it, you somehow mixed up.

  • Put the chromedriver.exe's path into PATH (on Windows), so your PATH setting is correct, but you need to call the default constructor.

    driver = webdriver.Chrome()

  • Specify the path in webdriver.Chrome(executable_path='some path'). Here you need the full path to the executable, not the directory.

    webdriver.Chrome(executable_path=r'C:\Users\HaranKumar\Downloads\chromedriver_win32_2.0\chromedriver.exe')

Choose either one you want.