【问题标题】:selenium.common.exceptions.WebDriverException: Message: 'Mozilla Firefox' executable may have wrong permissions while using GeckoDriverselenium.common.exceptions.WebDriverException:消息:“Mozilla Firefox”可执行文件在使用 GeckoDriver 时可能具有错误权限
【发布时间】:2018-06-08 19:31:26
【问题描述】:

我在尝试让 selenium 处理浏览器时遇到了一些麻烦。 我是这类东西的超级初学者,但我仍然搜索,我发现最相关的回应是我需要以管理员身份运行应用程序,但它没有改变任何东西。这是我的代码和错误消息。非常感谢。

import time
from selenium import webdriver
driver = webdriver.Firefox(executable_path="C:\Program Files\Mozilla Firefox")

我的错误信息:

Traceback (most recent call last):
  File "C:\Users\Axel\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Users\Axel\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Axel\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 997, 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:\Users\Axel\Desktop\PYTHON\code.py", line 3, in <module>
    driver = webdriver.Firefox(executable_path="C:\Program Files\Mozilla Firefox")
  File "C:\Users\Axel\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 160, in __init__
    self.service.start()
  File "C:\Users\Axel\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 88, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'Mozilla Firefox' executable may have wrong permissions. 

我很确定这两个错误只是一个错误,而且我已经经历了一大堆线程,但我从来没有正确理解事情。我想知道它是否与 geckdriver 有关(我没有也不知道如何安装。) 非常感谢!

【问题讨论】:

    标签: python selenium firefox selenium-webdriver geckodriver


    【解决方案1】:

    此错误消息...

    selenium.common.exceptions.WebDriverException: Message: 'Mozilla Firefox' executable may have wrong permissions.
    

    ...暗示 Mozilla Firefox 可执行文件由于权限错误而无法访问。

    在使用 Selenium v​​3.xGeckoDriverFirefox 时,您必须考虑以下某些事实:

    • 您需要通过 GeckoDriver 二进制文件的 绝对路径 来代替 Mozilla Firefox 二进制文件(即firefox.exe) >参数 单引号中的executable_path(即'')以及原始(r)开关。
    • 您需要从this link 下载最新版本的GeckoDriver,并确保GeckoDriver 具有非root 访问所需的权限> 用户。
    • 始终以 非 root 用户身份执行您的 TestCases/TestSuite
    • 你的有效代码块如下:

      from selenium import webdriver
      driver = webdriver.Firefox(executable_path=r'C:\path\to\geckodriver.exe')
      

    【讨论】:

      【解决方案2】:

      我相信对于 Firefox 版本 (47.0 +) 你需要使用 geckodriver。在这里查看:https://github.com/mozilla/geckodriver/releases

      【讨论】:

        猜你喜欢
        • 2018-03-22
        • 1970-01-01
        • 2022-01-19
        • 1970-01-01
        • 2018-07-11
        • 1970-01-01
        • 2019-06-13
        • 1970-01-01
        • 2018-09-22
        相关资源
        最近更新 更多