Error Message: 'chromedriver' executable needs to be PATH

流过昼夜 提交于 2019-12-27 12:07:27

问题


I just started on Selenium and was able to load up google but now when I run the following code it produces the error:

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

Why is it saying "C:Users/Colin/Python/chromedriver" is not a path?

from selenium import webdriver

browser = webdriver.Chrome("C:Users/Colin/Python/chromedriver")
browser.get('http://www.google.com')

browser.quit()

回答1:


While working with Selenium v3.x, ChromeDriver and Chrome Browser you may need to pass the argument executable_path along with the absolute path of the ChromeDriver binary through either of the following options:

  • Double back slashes i.e. (\\)
  • Single back slash i.e (\) along with the raw (r) switch.
  • Binary extension i.e. (.exe)

So you have to change the line :

browser = webdriver.Chrome("C:Users/Colin/Python/chromedriver")

With :

browser = webdriver.Chrome(executable_path=r'C:\Users\Colin\Python\chromedriver.exe')


来源:https://stackoverflow.com/questions/49201281/error-message-chromedriver-executable-needs-to-be-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!