python - 使用Python的 Selenium : Permission Denied to Launch Webdriver

标签 python selenium selenium-webdriver permissions permission-denied

我是一名 Python 初学者,正在尝试使用 selenium 来自动化网页浏览过程。不幸的是,我的尝试并不像我希望的那么顺利;无论出于何种原因,当我运行以下代码时,命令行返回一个错误,指出“权限被拒绝”:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('C:\Program Files (x86)\Mozilla Firefox')
browser = webdriver.Firefox(firefox_binary=binary)

print(type(browser))

我尝试阅读有关此主题的先前帖子 - 特别是 this onethat one ——但每一个都无济于事。编译器要么返回“权限被拒绝”,要么在将 firefox.exe 添加到路径末尾的情况下返回“找不到实体”。

非常感谢您能给我的任何帮助。如果你能像向 8 岁 child 那样解释任何帮助,那就特别有帮助——我对这方面还是个新手。

编辑添加:如果它有助于提供任何上下文,我正在使用 Windows 10 并在 Visual Studio Community 上运行 Python。我还考虑过使用 sudo 命令来获取权限,但我不太确定如何从 Visual Studio 中执行此操作。

最佳答案

尝试将 Firefox.exe 而不是 firefox.exe 添加到您的路径中。

我以前也遇到过这个问题,它对我有用,但我不确定为什么。

关于python - 使用Python的 Selenium : Permission Denied to Launch Webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40711768/

相关文章:

python - 无法按标签运行 django 测试

python - 在 SQLAlchemy 中合并多个声明性基础

c# - 使用 Xunit 运行 Specflow 但出现错误 nunit.framework

python - 该进程从 chrome 位置 C :\. 开始。\Chrome\Application\chrome.exe 不再运行,因此 ChromeDriver 假设 Chrome 已崩溃

java - 表中相关元素的 XPath

Python/Tkinter : pack equivalent of grid_remove(), 例如。 pack_remove()?

java - 如何在同一台机器上运行多个 selenium 测试套件

python - 当我在盒子上按下 onclick() 时出现 Selenium 问题

selenium - 如何在 Selenium Webdriver 2.x 中单击文本

python - 无法在 Windows 上导入 distutils.dir_util