使用Python Splinter Library时出错

时间:2013-07-24 01:16:07

标签: python splinter

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

有人在beaglebone arm7平台的命令行上安装了任何网络驱动程序吗?

未修改的代码

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"

2 个答案:

答案 0 :(得分:2)

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

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

  • 安装Firefox

  • 下载Chromedriver,以便selenium(splinter)浏览Google Chrome。有关设置Chromedriver
  • 的详细信息,请参阅此discussion

希望它有所帮助!

答案 1 :(得分:0)

我不确定(我只在实际桌面上运行了分裂)但我认为问题仅在于缺少指定的显示。在桌面上运行默认代码时,它会打开Web浏览器窗口。它必须在这里尝试相同。 既然你问了这个问题,你解决了这个问题吗?