Selenium无法使用chrome驱动程序 [英] Can't use chrome driver for Selenium

查看:656
本文介绍了Selenium无法使用chrome驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用Selenium的Chrome驱动程序。我有chromedriver下载并保存到C:\ Chrome:

I'm having trouble using the Chrome driver for Selenium. I have the chromedriver downloaded and saved to C:\Chrome:

driver = webdriver.Chrome(executable_path="C:/Chrome/")

使用该命令会出现以下错误:

Using that gives me the following error:

Traceback (most recent call last):
  File "C:\Python33\lib\subprocess.py", line 1105, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\service.py", line 63, in start
    self.service_args, env=env, stdout=PIPE, stderr=PIPE)
  File "C:\Python33\lib\subprocess.py", line 817, in __init__
    restore_signals, start_new_session)
  File "C:\Python33\lib\subprocess.py", line 1111, in _execute_child
    raise WindowsError(*e.args)
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Wilson/Dropbox/xxx.py", line 71, in <module>
    driver = webdriver.Chrome(executable_path="C:/Chrome/")
  File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 59, in __init__
    self.service.start()
  File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\service.py", line 68, in start
    and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.                 Please download from http://chromedriver.storage.googleapis.com/index.html  

任何帮助将不胜感激。

Any help would be appreciated.

推荐答案

您应该指定可执行文件路径,而不是

You should specify the executable file path, not the directory path that contains the executable.

driver = webdriver.Chrome(executable_path=r"C:\Chrome\chromedriver.exe")

这篇关于Selenium无法使用chrome驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆