使用Python Splinter库时出错

使用Python Splinter库时出错,python,splinter,Python,Splinter,我刚刚在我的beaglebone机器上安装了Splinter python库。 当我使用splinter网站上提供的示例时,我得到了一个错误。 我相信我需要安装一个webdriver才能让它工作 是否有人在beaglebone arm7平台的命令行上安装了任何web驱动程序 未修改代码 from splinter import Browser with Browser() as browser: # Visit URL url = "http://www.google.c

我刚刚在我的beaglebone机器上安装了Splinter python库。 当我使用splinter网站上提供的示例时,我得到了一个错误。 我相信我需要安装一个webdriver才能让它工作

是否有人在beaglebone arm7平台的命令行上安装了任何web驱动程序

未修改代码

from splinter import Browser

 with Browser() as browser:
     # Visit URL
     url = "http://www.google.com"
     browser.visit(url)
     browser.fill('q', 'splinter - python acceptance testing for web applications')
     # Find and click the 'search' button
     button = browser.find_by_name('btnG')
     # Interact with elements
     button.click()
     if browser.is_text_present('splinter.cobrateam.info'):
         print "Yes, the official website was found!"
     else:
         print "No, it wasn't found... We need to improve our SEO techniques" 
错误是

Traceback (most recent call last):
  File "http1.py", line 3, in <module>
    with Browser() as browser:
  File "build/bdist.linux-armv7l/egg/splinter/browser.py", line 44, in Browser
  File "build/bdist.linux-armv7l/egg/splinter/driver/webdriver/firefox.py", line 33, in __init__
  File "/usr/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 61, in __init__
    self.binary, timeout),
  File "/usr/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "/usr/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 51, in launch_browser
    self._wait_until_connectable()
  File "/usr/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 90, in _wait_until_connectable
    self._get_firefox_output())
selenium.common.exceptions.WebDriverException: Message: "The browser appears to have exited before we could connect. The output was: ERROR: ld.so: object 'x_ignore_nofocus.so' from LD_PRELOAD cannot be preloaded: ignored.\nError: no display specified\n"
回溯(最近一次呼叫最后一次):
文件“http1.py”,第3行,在
使用浏览器()作为浏览器:
浏览器中第44行的文件“build/bdist.linux-armv7l/egg/splinter/browser.py”
文件“build/bdist.linux-armv7l/egg/splinter/driver/webdriver/firefox.py”,第33行,在__
文件“/usr/lib/python2.7/site packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/webdriver.py”,第61行,在__
self.binary,超时),
文件“/usr/lib/python2.7/site packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/extension_connection.py”,第47行,在u init中__
self.binary.launch_浏览器(self.profile)
文件“/usr/lib/python2.7/site packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/firefox\u binary.py”,第51行,在launch\u浏览器中
self.\u等待\u直到\u可连接()
文件“/usr/lib/python2.7/site packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/firefox\u binary.py”,第90行,在“等待”直到“可连接”
self.\u获取\u firefox\u输出()
selenium.common.exceptions.WebDriverException:Message:“浏览器似乎在我们可以连接之前已退出。输出为:错误:ld.so:object'x_ignore\u nofocus。无法预加载来自ld_PRELOAD的so:ignored。\n错误:未指定显示\n”
我不确定(我只在实际的桌面上运行过splinter),但我认为问题只是缺少指定的显示。在桌面上运行默认代码时,会打开一个web浏览器窗口。这一定是在试图改变同样的情况。
自从你提出这个问题以来,你已经解决了这个问题吗?

可能有点晚了,但以防万一:

我也有同样的问题,因为我没有安装Firefox。Splinter基于selenium,它使用默认浏览器Mozilla Firefox,因此:

  • 安装Firefox

  • 下载Chromedriver,以便selenium(splinter)通过谷歌浏览器浏览。有关设置Chromedriver的更多信息,请参见此
希望有帮助