【问题标题】:Jenkins not able to open a firefox window selenium (python )詹金斯无法打开一个Firefox窗口硒(python)
【发布时间】:2014-02-19 09:40:47
【问题描述】:

我能够完美地运行我的 Python 代码(main.py)。当我使用 Jenkins 运行我的 Python 代码(main.py)时,就会出现问题。 Jenkins 无法启动 Firefox。

线 driver = webdriver.Firefox() 正在抛出异常行:

Entering main()
Traceback (most recent call last):
  File "main.py", line 21, in <module>
    driver = webdriver.Firefox()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
    self.binary, timeout),
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 61, in launch_browser
    self._wait_until_connectable()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 100, 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: \n(process:9287): GLib-CRITICAL **: g_slice_set_config: assertion `sys_page_size == 0' failed\nError: no display specified\n" 
Finished: SUCCESS


#############  Code snippet ###########

if __name__ ==  __main__  :

     driver = webdriver.Firefox()
     driver.implicitly_wait(10)
     driver.get("www.google.com")

【问题讨论】:

  • 需要指定显示编号。或者您不使用 firefox 而是使用 phantomjs。看看这两种可能性。

标签: python firefox selenium jenkins


【解决方案1】:

您是否使用 Windows 平台并将 Jenkins 作为 Windows 服务运行?

如果是这样,那么补救措施就是从命令行运行 Jenkins。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-30
    相关资源
    最近更新 更多