我能够完全运行我的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")
答案 0 :(得分:0)
您是否在Windows平台上运行Jenkins作为Windows服务?
如果是这样,那么补救措施就是从命令行运行Jenkins。