2013-07-24 38 views
1

我剛剛在我的beaglebone機器上安裝了Splinter python庫。 當我使用分裂網站上提供的示例時,出現錯誤。 我相信我需要安裝一個webdriver才能正常工作。使用Python分裂庫的錯誤

有沒有人在命令行中爲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" 

回答

0

我不知道(我只跑了一個實際的桌面上分裂出來的),但我認爲這個問題是隻與缺乏的指定顯示。當您在桌面上運行默認代碼時,它會打開一個Web瀏覽器窗口。它必須在這裏嘗試。 你問這個問題後,你解決了這個問題嗎?

2

它可能是一個有點晚了,但以防萬一:

我有同樣的問題,因爲我沒有安裝Firefox瀏覽器。分裂是基於硒,它使用它的默認瀏覽器是Mozilla Firefox所以無論是:

  • 安裝Firefox

  • 下載Chromedriver使硒(碎片)瀏覽通過谷歌鉻。看到這discussion進一步的信息設置Chromedriver

希望它有幫助!