【问题标题】:Python selenium not workingPython硒不起作用
【发布时间】:2016-05-24 19:52:42
【问题描述】:

我有一个不工作的简单 python 脚本:

#!/usr/bin/env python

from selenium import webdriver


browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/')

但是当我尝试运行它时收到此错误:

Traceback (most recent call last):
  File "./test.py", line 5, in <module>
    browser = webdriver.Firefox()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 103, in __init__
    self.binary, timeout)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 98, in _wait_until_connectable
    raise WebDriverException("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.

我正在运行 selenium 版本:

Name: selenium
Version: 2.53.2

火狐版本:

ii  firefox-mozilla-build            14.0.1-0ubuntu1                  amd64        Mozilla Firefox, official Mozilla build, packaged for Ubuntu by the Ubuntuzilla project.

【问题讨论】:

  • 您是否尝试过此处列出的解决方案? stackoverflow.com/questions/26070834/…
  • @lonewaft 刚试过。没有解决问题。我相信 selenium 和 firefox 的版本之间存在问题。但是还没有找到任何关于哪个版本的 selenium 支持 firefox 等的文档。
  • 附注:你应该更新你的浏览器,它已经很老了。最新版本是 46.0.1。
  • 我尝试了多个版本的 Firefox。最新、旧等以使其正常工作。

标签: python selenium ubuntu firefox


【解决方案1】:

为了使用最新的 selenium,您需要使用最新的 firefox。您的 Firefox 版本严重过时。

然后,确保您可以从命令行打开 Firefox。只需在终端中输入firefox

最后,确保更新 python 的 selenium:sudo pip install -U selenium

【讨论】:

    猜你喜欢
    • 2017-08-06
    • 1970-01-01
    • 2018-12-15
    • 2016-08-31
    • 1970-01-01
    • 2011-02-02
    • 2017-11-14
    • 1970-01-01
    • 2018-08-02
    相关资源
    最近更新 更多