【问题标题】:Selenium Firefox Profile not workingSelenium Firefox 配置文件不起作用
【发布时间】:2016-04-20 02:14:34
【问题描述】:

我正在尝试加载我的 selenium 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.

代码在 15 分钟前运行良好。我不确定发生了什么。

我有 firefox 43.0.4 和 selenium 2.49

这是我抛出错误的代码:

profile = webdriver.FirefoxProfile()
driver = webdriver.Firefox(profile)

我正在使用 Windows 7 Professional,Python 2.7.10 | Anaconda 2.3.0(64 位)

追溯:

    Traceback (most recent call last):
  File "C:\Users\Moyp\dev\anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3035, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-15-37f7d14be053>", line 2, in <module>
    driver = webdriver.Firefox(profile)
  File "C:\Users\Moyp\dev\anaconda\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 77, in __init__
    RemoteWebDriver.__init__(self,
  File "C:\Users\Moyp\dev\anaconda\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 49, in __init__
    self.binary.launch_browser(self.profile)
  File "C:\Users\Moyp\dev\anaconda\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable()
  File "C:\Users\Moyp\dev\anaconda\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 103, in _wait_until_connectable
    raise WebDriverException("Can't load the profile. Profile "
WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.

【问题讨论】:

  • 在 Python 2.7 和 Python 3.5 上使用 MacOS、Selenium 2.49 和 Firefox 43.0.4 进行测试 - 没有错误。您能否分享有关您的设置、您执行的代码和完整回溯的更多详细信息?
  • 我只是添加了更多细节,我执行的代码是我发布的 2 行
  • 刚刚又更新了traceback,之前记错了
  • 快速检查一下:您能import selenium 并在您的IPython 终端中打印出selenium.__version__ 吗?谢谢。
  • 说它的'2.46.1',我刚刚重新启动了pycharm,它说'2.49',代码现在可以工作了。谢谢!

标签: python firefox selenium


【解决方案1】:

不同的 selenium 版本与某些 Firefox 版本存在兼容性问题。 Selenium 2.49 和 Firefox 43 可以很好地协同工作。

确保您确实在使用selenium 2.49

import selenium
print(selenium.__version__) 

【讨论】:

    【解决方案2】:

    我遇到了类似的问题,问题是在启动无头虚拟显示后我没有停止它。所以他们都在后台运行。运行top命令,测试完成后检查是否有浏览器firefox在运行。

    【讨论】:

      【解决方案3】:

      个人资料存在一些已知问题。根据 Selenium 发行说明,您不应再使用 profile = webdriver.FirefoxProfile(profilepath)...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-08-02
        • 1970-01-01
        • 2016-09-11
        • 2016-03-31
        • 2016-09-14
        • 1970-01-01
        • 2017-08-07
        • 1970-01-01
        相关资源
        最近更新 更多