简体   繁体   中英

Error using Python Splinter Library

I have just installed Splinter python library on my beaglebone machine. When I use the example provided on the splinter website, I get an error. I believe I am required to install a webdriver for this to work.

has anyone installed any of the web drivers on the commandline for beaglebone arm7 platform?

Unmodified code

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" 

And the error is

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"

It may be a little too late, but just in case:

I had the same problem because I didn't have Firefox installed. Splinter is based on selenium, which uses as it's default browser Mozilla Firefox so either:

  • install Firefox

or

  • download the Chromedriver so that selenium (splinter) browses through Google Chrome. See this discussion for further information on setting up Chromedriver

Hope it helps!

I'm not sure (I have only ran splinter on an actual desktop) but I think the issue is only with the lack of specified display. When you run the default code on a desktop, it opens a web browser window. It must be trying to to the same here. Have you solved the problem since you asked the question?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM