selenium镀铬在jenkins奴隶崩溃

我试图在无头模式下使用selenium运行UItesting。 我看到铬是浏览器崩溃,每当我尝试加载驱动程序。 这是追溯。

Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/behave/model.py", line 1456, in run match.run(runner.context) File "/usr/local/lib/python3.5/dist-packages/behave/model.py", line 1903, in run self.func(context, *args, **kwargs) File "steps/collectorUi.py", line 35, in step_impl assert context.ndpUt.driverInit(title="Pegasus Portal") is not False, 'Initial page title didnt match' File "../collectorSanity/libs/ndpUi.py", line 91, in driverInit browser=self.browser) File "../runner/testutils/seleniumutils.py", line 70, in __init__ executable_path=self.browserPath+self.browserDriver) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__ desired_capabilities=desired_capabilities) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__ self.start_session(desired_capabilities, browser_profile) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session response = self.execute(Command.NEW_SESSION, capabilities) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.2.0-16-generic x86_64) 

我在Ubuntu上安装了xvfb和google-chrome。 以下是我在运行testing之前设置的环境variables。

ENV:

 export DISPLAY=:10 nohup sudo Xvfb :10 -ac -screen 0 1900x980x24 & 

当我在泊坞窗容器中运行时,我得到以下错误。

 jenkins@26cccde068c0:~/e2e$ nohup sudo Xvfb :10 -ac -screen 0 1900x980x24 & _XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root (EE) Fatal server error: (EE) Server is already active for display 10 If this server is no longer running, remove /tmp/.X10-lock and start again. (EE) 

在selenium库中,以下是铬驱动程序的显示和参数。

 from pyvirtualdisplay import Display from selenium import webdriver class SeleniumUi(object): def __init__(self, ....): if isHeadless: self.display = Display(visible=0, size=(1900, 980)) self.display.start() # secure if secure: self.webpage = 'https://{}{}'.format(self.hostname, webpageUri) else: self.webpage = 'http://{}{}'.format(self.hostname, webpageUri) # firefox options if self.browser.lower() == 'firefox': if ignoreCert: # ignoring the certs self.profile = webdriver.FirefoxProfile() self.profile.accept_untrusted_certs = True self.driver = webdriver.Firefox(firefox_profile=self.profile) else: self.driver = webdriver.Firefox() # chrome options elif self.browser.lower() == 'chrome': #os.system('killall -9 chromedriver') self.options = webdriver.ChromeOptions() self.options.add_argument('--dns-prefetch-disable') #self.options.add_argument("--disable-extensions") # don't delete this self.options.add_argument('--disable-web-security') self.options.add_argument('--window-size=1400,900') #self.options.add_argument('--allow-file-access-from-files') #self.options.add_argument('--allow-file-access') #self.options.add_argument('--allow-cross-origin-auth-prompt') #self.options.add_argument('--allow-control-allow-origin') #self.options.add_argument('--allow-control-allow-methods') #self.options.add_argument('--allow-control-allow-headers') #self.options.add_argument('--disable-default-apps') if ignoreCert: # ignoring the certs self.options.add_argument('--ignore-certificate-errors') log.debug('browserPath:{} browserDriver:{}'.format(self.browserPath, self.browserDriver)) self.driver = webdriver.Chrome(chrome_options=self.options, executable_path=self.browserPath+self.browserDriver) 

请让我知道可能是什么问题。 提前致谢。