Can I still specify a path to chromedriver using ChromeOptions in Python?

Ann Colvin picture Ann Colvin · Apr 13, 2017 · Viewed 8.1k times · Source

I received this error: "WebDriverException: Message: 'chromedriver' executable needs to be in PATH." The only way I was able to fix it was to manually add one of the locations of chromedriver like this:

driver = webdriver.Chrome("/Users/anncolvin/.rvm/bin/chromedriver")

After Chrome launched, I then received this error: "You are using an unsupported command-line flag: --ignore-certifcate-errors. Stability and security will suffer."

I'd like to try using the following code to address this new error but I don't know how/if I can combine it with manually specifying chromedriver's location?

options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["ignore-
certificate-errors"])
browser = webdriver.Chrome(chrome_options=options)
browser.get("http://google.com/")

Answer

kurczynski picture kurczynski · Jul 13, 2017

All you have to do is specify the webdriver location as an argument when calling the Chrome webdriver like so:

chrome_path = r"/Users/anncolvin/.rvm/bin/chromedriver"
browser = webdriver.Chrome(chrome_path, chrome_options=options)