简体   繁体   English

硒无法连接到Firefox

[英]selenium does not connect to firefox

I am trying to use the Selenium bindings for Python. 我正在尝试将Selenium绑定用于Python。 When I execute webdriver.Firefox() , the windows opens, but the method never returns. 当我执行webdriver.Firefox() ,窗口将打开,但该方法永远不会返回。 After a while, the window closes again and I get the following exception: 一段时间后,该窗口再次关闭,并且出现以下异常:

>>> driver = webdriver.Firefox()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 77, in __init__
    self.binary, timeout),
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 49, in __init__
    self.binary.launch_browser(self.profile)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable()
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 103, in _wait_until_connectable
    raise WebDriverException("Can't load the profile. Profile "
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.

Per this question I checked my version. 根据这个问题,我检查了我的版本。 I'm running selenium version 2.47.3, and Firefox version 40.0.3. 我正在运行硒版本2.47.3和Firefox版本40.0.3。 Both are the most recent available versions, so they should be compatible. 两者都是最新的可用版本,因此它们应该兼容。

as the exception says, it looks like your Firefox profile folder is missing or inaccessible. 例外情况是,您的Firefox配置文件文件夹似乎丢失或无法访问。

The profile folder was either moved, renamed or deleted. 配置文件文件夹已被移动,重命名或删除。

By default the profile folder is under the ~/.mozilla/firefox 默认情况下,配置文件文件夹位于~/.mozilla/firefox

Please follow this guide to recover it. 请按照本指南进行恢复。 Also check this other Q&A 还要检查此其他问答

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

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