2014-02-19 90 views
0

我能够运行我的Python代码(main.py)完全没问题。当我使用Jenkins来运行我的Python代码(main.py)时,问题就发生了。 Jenkins无法启动Firefox。Jenkins无法打开Firefox窗口硒(Python)

线 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") 
+0

您需要指定显示号码。或者你不使用firefox,而是使用phantomjs。看看两种可能性。 – User

回答

0

你在Windows平台上运行詹金斯作为Windows服务?

如果是这样,那么补救措施将是从命令行运行詹金斯。