4

我安装了 selenium-python 绑定并尝试创建一个 Firefox Web 驱动程序实例,如下所示

>>> from selenium import webdriver
>>> driver = webdriver.Firefox()

我不知道这里出了什么问题并显示以下错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 51, in __init__
    self.binary, timeout),
  File "/usr/lib/python2.7/site-packages/selenium-2.21.3-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.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 44, in launch_browser
    self._wait_until_connectable()
  File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 81, 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: cannot open display: :1100\n' 

任何人都可以让我知道如何解决这个问题............

4

1 回答 1

1

错误说“无法打开显示::1100”。你是在远程终端上运行它吗?确保您可以在提示符下键入“firefox”并打开浏览器(这就是 Webdriver 所做的 - 在您的系统上打开 Firefox,然后尝试连接到它)。如果您在远程系统上运行它,请在远程连接到 X 显示器时进行网络搜索。

于 2012-07-02T10:17:28.700 回答