这是我第一次尝试使用 Iceweasel 浏览器在树莓派上运行 Selenium。今天晚上我尝试了一个简单的测试
# selenium test for /mod2
# verify: posts, and page name
class TestMod2Selenium(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
def test_validate_page_elements(self):
driver = self.driver
driver.get("127.0.0.1:5000/mod2")
self.assertIn("Home - microblog", driver.title)
def tearDown(self):
self.driver.close()
我在运行时得到的错误是:
=====================================================================
ERROR: test_validate_page_elements (__main__.TestMod2Selenium)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test.py", line 58, in setUp
self.driver = webdriver.Firefox()
File "/home/pi/naughton_python/flask/flask/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
self.binary, timeout),
File "/home/pi/naughton_python/flask/flask/local/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/home/pi/naughton_python/flask/flask/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 61, in launch_browser
self._wait_until_connectable()
File "/home/pi/naughton_python/flask/flask/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 100, in _wait_until_connectable
self._get_firefox_output())
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: ld.so: object 'x_ignore_nofocus.so' from LD_PRELOAD cannot be preloaded: ignored.\nERROR: ld.so: object 'x_ignore_nofocus.so' from LD_PRELOAD cannot be preloaded: ignored.\nError: no display specified\n"
根据我在网上阅读的内容,我了解到 Iceweasel 在 pi 上充当 Firefox 的替代品,许多人声称您所要做的就是调用 firefox webdriver 来使用它。我只是做错了吗?
感谢您的时间。