Jenkins:Ubuntu 16.04:无头Chrome无法启动:异常退出

时间:2018-10-16 01:43:51

标签: ubuntu jenkins jenkins-plugins robotframework headless

  

jenkins @ ubuntu:〜$ chromedriver   / usr / local / bin / chromedriver

     

ChromeDriver 2.42.591071(0b695ff80972cc1a65a5cd643186d2ae582cd4ac)

我正在尝试运行Jenkins的一些Robot框架脚本。我的机器人脚本在Ubuntu16.04版计算机上无头运行。

每次运行测试用例甚至是简单的Selenium脚本时,都会出现以下错误:

>>> from selenium import webdriver
    we = webdriver.Chrome()
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/var/lib/jenkins/.local/lib/python2.7/site- 
    packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
    File "/var/lib/jenkins/.local/lib/python2.7/site- 
    packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
   self.start_session(capabilities, browser_profile)
   File "/var/lib/jenkins/.local/lib/python2.7/site- 
   packages/selenium/webdriver/remote/webdriver.py", line 252, in 
   start_session
   response = self.execute(Command.NEW_SESSION, parameters)
   File "/var/lib/jenkins/.local/lib/python2.7/site- 
   packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
   self.error_handler.check_response(response)
   File "/var/lib/jenkins/.local/lib/python2.7/site- 
   packages/selenium/webdriver/remote/errorhandler.py", line 242, in 
   check_response
   raise exception_class(message, screen, stacktrace)
   selenium.common.exceptions.WebDriverException: Message: unknown 
   error: Chrome failed to start: exited abnormally
   (unknown error: DevToolsActivePort file doesn't exist)
   (The process started from chrome location /usr/bin/google-chrome is 
    no longer running, so ChromeDriver is assuming that Chrome has 
   crashed.)
   (Driver info: chromedriver=2.42.591071 
  (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.4.0-87- 
  generic x86_64)
  

要使其无头运行,我需要执行以下操作:   Xvfb -ac:90 -screen 0 1280x1024x16&   导出DISPLAY =:90

在解决此问题方面的任何帮助将不胜感激。

谢谢!

1 个答案:

答案 0 :(得分:0)

为解决此问题,我将google-chrome版本降级为57.0.2987.133和chromedriver版本2.26.436382(70eb799287ce4c2208441fc057053a5b07ceabac)。

似乎新版本的chromedriver和google-chrome在针对机器人脚本的ubuntu 14.04中无头运行它们时会遇到一些问题。

为了无头运行它,我曾经使用过:

Xvfb -ac:90 -screen 0 1280x1024x16& 导出DISPLAY =:90