在 ubuntu 上从 python 启动 selenium [英] launch selenium from python on ubuntu

查看:44
本文介绍了在 ubuntu 上从 python 启动 selenium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下脚本

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 正常工作.尝试使用 46 或 45.

The last version of Firefox is not working properly with selenium. Try with 46 or 45.

你可以在这里下载:ftp.mozilla.org/pub/firefox/releases

You can download here: ftp.mozilla.org/pub/firefox/releases

sudo apt-get install firefox=45.0.2+build1-0ubuntu1

您也可以以图形方式执行此操作,如下所示 http://www.howtogeek.com/117929/how-to-downgrade-packages-on-ubuntu/

You can also do this graphically as shown here http://www.howtogeek.com/117929/how-to-downgrade-packages-on-ubuntu/

这篇关于在 ubuntu 上从 python 启动 selenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆