selenium.common.exceptions.WebDriverException:消息:"Mozilla Firefox"可执行文件在使用GeckoDriver时可能具有错误的权限 [英] selenium.common.exceptions.WebDriverException: Message: 'Mozilla Firefox' executable may have wrong permissions while using GeckoDriver

查看:299
本文介绍了selenium.common.exceptions.WebDriverException:消息:"Mozilla Firefox"可执行文件在使用GeckoDriver时可能具有错误的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用硒来完成浏览器操作时遇到了一些麻烦. 我是这种类型的超级入门者,但我仍然进行搜索,发现的最相关的响应是我需要以管理员身份运行该应用程序,但它没有任何改变.这是我的代码和错误消息.非常感谢.

I've had some trouble trying to get selenium to do stuff with browsers. I'm a super-beginner at this type of stuff, but I still searched, and the most pertinent response I found was that I needed to run the Application as administrator, but it didn't change anything. Here's my code and the error message. Thanks alot.

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有关(我没有,也不知道如何安装.) 非常感谢!

I'm pretty sure these two errors are just one, and I've gone through a whole bunch of threads, but i never properly understand things. I wondered if it had something to do with geckdriver (which i havem't and don't know how to install.) Thanks alot!

推荐答案

此错误消息...

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

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

...implies that the Mozilla Firefox executable was unaccessable due to wrong permissions.

在使用 Selenium v​​3.x GeckoDriver Firefox 时,您必须考虑以下事实:

While working with Selenium v3.x, GeckoDriver and Firefox you have to consider certain facts as follows:

  • Instead of Mozilla Firefox binary (i.e. firefox.exe) you need to pass the absolute path of the GeckoDriver binary through the argument executable_path within single quotes (i.e. '') along with the raw (r) switch.
  • You need to download the latest release of GeckoDriver from this link and ensure that GeckoDriver have required permissions to be accessed by non-root user.
  • Always execute your TestCases/TestSuite as a non-root user.
  • Your effective code block will be as follows:

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

这篇关于selenium.common.exceptions.WebDriverException:消息:"Mozilla Firefox"可执行文件在使用GeckoDriver时可能具有错误的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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