简体   繁体   English

Selenium Firefox Profile无法正常工作

[英]Selenium Firefox Profile not working

I am trying to load my selenium firefox profile and I keep getting the error: 我正在尝试加载我的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.

The code was working fine 15 minutes ago.. I am not sure what happened. 该代码在15分钟前工作正常..我不确定发生了什么。

I have firefox 43.0.4 and selenium 2.49 我有firefox 43.0.4和selenium 2.49

This is my code that throws an error: 这是我抛出错误的代码:

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

I am using Windows 7 Professional, Python 2.7.10 | 我使用的是Windows 7 Professional,Python 2.7.10 | Anaconda 2.3.0 (64-bit) Anaconda 2.3.0(64位)

Traceback: 追溯:

    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.

Different selenium versions have compatibility issues with certain Firefox versions. 不同的selenium版本与某些Firefox版本存在兼容性问题 Selenium 2.49 and Firefox 43 work together well. Selenium 2.49和Firefox 43很好地协同工作。

Make sure you are really using selenium 2.49 : 确保你真的使用selenium 2.49

import selenium
print(selenium.__version__) 

I had the similar issue, the issue was after starting virtual display for headless I wasn't stopping it. 我有类似的问题,问题是在无头启动虚拟显示后我没有停止它。 So all of them were running in background. 所以他们都在后台运行。 Run top command and check if there is not browser firefox running after tests are finished. 运行top命令并检查测试完成后是否没有运行浏览器firefox

There are some know issues with profiles. 配置文件存在一些已知问题。 As per the Selenium release notes you shouldn't be using profile = webdriver.FirefoxProfile(profilepath) anymore... 根据Selenium发行说明,你不应该再使用profile = webdriver.FirefoxProfile(profilepath) ......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM