当前位置: 首页 > 面试题库 >

不能将chrome驱动程序用于Selenium

梁丘缪文
2023-03-14
问题内容

我在将Chrome驱动程序用于Selenium时遇到问题。我已下载chromedriver,并将其保存到C:\ Chrome:

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

使用它给我以下错误:

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

任何帮助,将不胜感激。


问题答案:

您应该指定可执行文件路径,而不是包含可执行文件的目录路径。

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


 类似资料:
  • 我正在尝试使用Selenium web驱动程序。我正在使用asp。net mvc。我已经设置了一个非常基本的测试。我基本上只是想打开浏览器。 但当我运行测试我得到这个错误消息 结果消息: 文件c:\chromedriver.exe\chromedriver.exe不存在。驱动程序可以在http://chromedriver.storage.googleapis.com/index.html下载 我

  • 问题内容: 我正在尝试运行一个ruby文件,该文件将使用seleniumwebdriver启动chrome驱动程序。我有selenium独立服务器2.35.0。和chromedriver可执行文件已安装。我正在通过运行服务器来启动 两个会话正在启动,chrome驱动程序无法启动。 这是在我使用以下文件运行文件之后 我对此并不陌生,无法找出问题所在。而且,我也试图让它无头运行,所以我正在运行Xvfb

  • 我试图运行一个ruby文件,这将启动chrome驱动程序使用selenium WebDriver。我有selenium独立服务器2.35.0。和chromedriver可执行文件安装。我通过运行来启动服务器, 这是在我使用 我对此很陌生,不知道哪里出了问题。我也试图无头运行它,所以我有Xvfb运行。有人能帮我指出我犯的错误并启动chromedriver吗? 更新: 谁能帮我弄清楚出了什么问题吗?

  • 我想在VS 2010 C#中使用Selenium Web驱动程序打开Chrome浏览器,导航到某个网页,然后关闭驱动程序,但保持浏览器打开。我意识到,我将不得不手动关闭浏览器后,我同意这一点。 到目前为止我有: 我已经尝试了以下所有作为最后一行 有什么想法吗?

  • 当我尝试用Selenium 3.14、3.13或3.12启动WebDriver时,我得到 “org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器的地址无效或浏览器启动失败。”错误。 我可以用旧的Selenium版本运行测试而没有错误。我已经设置了环境变量(例如webdriver.chrome.drive

  • 对于ex,当我的chrome放在Compand提示符中时,会给出路径-/applications/google\chrome.app system.setproperty(“webdriver.chrome.driver”,“/applications/google/chrome.app”);WebDriver driver=new ChromeDriver(); driver.get(“http