【发布时间】:2017-01-21 12:45:23
【问题描述】:
我有以下脚本
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://localhost:8000')
assert 'Django' in browser.title
我收到以下错误
$ python3 functional_tests.py
Traceback (most recent call last): File "functional_tests.py", line 3, in <module>
browser = webdriver.Firefox() File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 80, in __init__
self.binary, timeout) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 52, in __init__
self.binary.launch_browser(self.profile, timeout=timeout) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
self._wait_until_connectable(timeout=timeout) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 99, in _wait_until_connectable
"The browser appears to have exited " selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
pip3 list 显示selenium (2.53.6)。
firefox -v 显示Mozilla Firefox 47.0。
【问题讨论】:
-
听起来像是兼容性问题:您安装了哪些 firefox 和 selenium 版本?
-
最新版本的 Firefox 无法与 selenium 一起正常工作。试试 46 或 45。你可以在这里下载ftp.mozilla.org/pub/firefox/releases
-
做到了。
sudo apt-get install firefox=45.0.2+build1-0ubuntu1降级。 @TalesPádua 如果您将其写为答案,我很乐意将其作为正确答案。 -
@HarryMoreno,完成! =)