【问题标题】:WebDriverException: Message: Can't load the profile. At a loss as to what is happeningWebDriverException:消息:无法加载配置文件。不知所措
【发布时间】:2016-08-21 02:26:44
【问题描述】:

我已经使用 webdriver.Firefox() 多年了,今天我开始了另一个项目,browser = webdriver.Firefox() 正在返回

WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.

我已尝试将 C:\Program Files (x86)\Mozilla Firefox\firefox.exe 添加到我的 PATH 中。我试过pip install -U selenium。我试过了

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

profile = FirefoxProfile("C:\Users\Me\AppData\Roaming\Mozilla\Firefox\Profiles\8u2w2ge1.Me")
browser = webdriver.Firefox(profile)

我已将插件检查兼容性添加到我的 Firefox 插件中。没有,没有任何工作,同样的错误,Python 2.7.11,Windows 10 x64

这是我得到的一般回溯。

Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    browser = webdriver.Firefox(firefox_binary=binary)
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 80, in __init__
    self.binary, timeout)
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 108, in _wait_until_connectable
    % (self.profile.path))
WebDriverException: Message: Can't load the profile. Profile Dir: c:\users\me\appdata\local\temp\tmpwvgny8 If you specified a log_file in the FirefoxBinary constructor, check it for details.

有人知道为什么在临时目录中创建此配置文件时遇到问题吗?一些新的方法来强制它存在于配置文件中,因为我的旧方法不起作用。

【问题讨论】:

  • 你需要尝试将C:\Program Files (x86)\Mozilla Firefox添加到没有exe的路径。
  • &gt;dir c:\users\me\appdata\local\temp\tmpwvgny8的结果是什么?
  • 是否期待来自此地址的配置文件:消息:无法加载配置文件。配置文件目录:c:\users\me\appdata\local\temp\tmpwvgny8 ?
  • @randominstanceOfLivingThing 我删除了 firefox.exe 我得到了相同的结果。这是一个看起来和我的普通配置文件非常相似的文件夹,保存所有插件的东西。
  • @AbirKhan 我相信是的,当我查看时,配置文件文件夹就在那里。

标签: python selenium firefox


【解决方案1】:

我实际上已经找到了解决这个问题的方法,它并不完美,我实际上是通过 chromedriver 使用 chrome,因为它更稳定一些,但是要使用 firefox,您可能需要下载 geckodriver 并将其包含在您在浏览器设置中的系统路径或路径,https://github.com/mozilla/geckodriver/releases,似乎是他们保留发布的地方,chrome 有一个chromedriver,其功能和使用方式大致相同。我不确定为什么我们需要这些新驱动程序在 Windows 中使用 selenium,但这就是生活,希望这可以为其他人节省一些工作。

【讨论】:

    猜你喜欢
    • 2016-06-22
    • 2013-12-29
    • 2011-11-11
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-07
    • 1970-01-01
    相关资源
    最近更新 更多