未知错误:Chrome无法启动:exception退出(驱动程序信息:chromedriver = 2.9

我试图在Debian 7上运行Seleniumtesting,但没有成功。

错误是:

unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9.248316,platform=Linux 3.2.0-4-686-pae x86) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 60.55 seconds Build info: version: '2.33.0', revision: '4ecaf82108b2a6cc6f006aae81961236eba93358', time: '2013-05-22 12:00:17' System info: os.name: 'Linux', os.arch: 'i386', os.version: '3.2.0-4-686-pae', java.version: '1.7.0_25' Driver info: org.openqa.selenium.chrome.ChromeDriver 

我有chromedriver 29Debian 7 32位上运行的chrome 34.0.1847.76 beta 。 我正在使用selenium-java 2.33.0

在这个链接之后 , chromedriver 29是合适的版本。 无论如何,由于glibc版本,以前的版本不能在Debian 7上运行…

 ---------- ChromeDriver v2.9(2014-01-31)----------
支持Chrome v31-34

[更新1]

我试着与Java 7Java 6 ,仍然是同样的问题。 可能是我应该尝试用java 8 ^^

[更新2]

我正在使用这个命令来testingchrome驱动程序,以确保jenkins不是问题:

 curl -X POST -H“Content-Type:application / json; charset = utf-8”-d“{\”desiredCapabilities \“:{\”platform \“:\”ANY \“,\”browserName \“: \ “铬\”,\ “chromeOptions \”:{\ “ARGS \”:[],\ “扩展\”:[]},\ “版本\”:\ “\” \ “chrome.switches \” :[]}}“localhost:12495 / session

我得到相同的错误信息:

 {“sessionId”:“210f3f837a798ee68cd91f089976d0c2”,“status”:13,“value”:{“message”:“未知错误:Chrome无法启动:exception退出\ n(驱动程序信息:chromedriver = 2.9.248316,platform = Linux 3.2.0-4-686-pae x86)“}}

任何帮助知道发生了什么,将不胜感激。

谢谢

我终于设法让我的笔记本电脑(服务器)上启动Chrome驱动程序的seleniumtesting。

重要的是使用Xvfb 。 不要问我为什么,但一旦你接受这个事实,请按照这些步骤(比@Anon答案更详细)

  • 在你jenkins设置中添加一个全局属性

     key : DISPLAY value:0:0 
  • 在你的服务器上在后台启动Xvfb

      Xvfb :0 -ac -screen 0 1024x768x24 & 

你是否将DISPLAYparameter passing给Jenkins作业?

我假设你也试图在无头模式下执行testing。 所以设置一些x服务(即Xvfb)并将DISPLAY编号传递给您的工作。 为我工作。

我试图用Jena和Wocha在Mocha框架上运行selenium。 所以下面是解决这个问题的步骤:

安装谷歌浏览器

 sudo apt-get update sudo apt-get install google-chrome-stable 

安装铬驱动程序

 wget http://chromedriver.storage.googleapis.com/2.23/chromedriver_linux64.zip unzip chromedriver_linux64.zip 

运行以下命令启动seleniumweb服务器

 nohup sudo Xvfb :10 -ac export DISPLAY=:10 java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.chrome.bin="/usr/bin/google-chrome" -Dwebdriver.chrome.driver="vendor/bin/chromedriver" 

开始之后,您将使用wdio命令进行testing

 wdio wdio.conf.js 

将no-sandbox传递给exec对于前台窗口中的jenkins或服务是非常重要的。 这是我的解决scheme

在运行在前景​​的窗口jenkins奴隶chromedriver失败

Mike R的解决scheme适用于我。 这是一套完整的命令:

 Xvfb :99 -ac -screen 0 1280x1024x24 & export DISPLAY=:99 nice -n 10 x11vnc 2>&1 & 

之后你可以运行google-chrome:

 google-chrome --no-sandbox & 

或者通过selenium驱动程序启动google chrome(例如):

 ng e2e --serve true --port 4200 --watch true 

Protractor.conf文件:

 capabilities: { 'browserName': 'chrome', 'chromeOptions': { 'args': ['no-sandbox'] } }, 

我们在尝试从Jenkins启动Seleniumtesting时遇到同样的问题。 我select了“ 在构build之前启动Xvfb,然后closures它 ”,然后传入必要的屏幕选项,但是我仍然遇到了这个错误。

当我们在Execute Shell框中传入以下命令时,它终于奏效了。

Xvfb :99 -ac -screen 0 1280x1024x24 & nice -n 10 x11vnc 2>&1 & ... killall Xvfb

导出DISPLAYvariables绝对是解决scheme,但取决于您的设置,您可能需要以稍微不同的方式来完成此操作。

就我而言,我有两个不同的过程:第一个启动Xvfb,另一个启动testing。 所以我的shell脚本知识有点生疏,但是我发现从第一个进程中导出DISPLAYvariables并没有使它在第二个进程中可用。

幸运的是,Selenium WebDriver可以让你“重新定义”你的环境。 这是我在JS中为Chrome创build驱动程序的function。 相当肯定你的编程语言的等价物存在:

 const caps = require('selenium-webdriver/lib/capabilities'); const chrome = require('selenium-webdriver/chrome'); const chromedriver = require('chromedriver'); module.exports = function (cfg) { let serviceBuilder = new chrome.ServiceBuilder(chromedriver.path); let options = chrome.Options.fromCapabilities(caps.Capabilities.chrome()); let service; let myENV = new Map(); // 're-export' the `DISPLAY` variable myENV.set('DISPLAY', ':1'); serviceBuilder.setEnvironment(myENV); service = serviceBuilder.build(); options.addArguments('disable-setuid-sandbox'); options.addArguments('no-sandbox'); options.addArguments('allow-insecure-localhost'); options.excludeSwitches('test-type'); return chrome.Driver.createSession(options, service); }; 

我在terminal中使用了x86 linux上的Maventesting。 我是通过SSHlogin到Linux。 我开始了我的javaseleniumtesting

 mvn -DargLine="-Dbaseurl=http://http://127.0.0.1:8080/web/" install 

除了我的应用程序,运行这些testing后,我收到日志中的错误:

 unknown error: Chrome failed to start: exited abnormally 

我以root用户身份运行这些testing。 在我收到这个错误之前,ChromeDriver不存在。 我通过安装ChromeDriver二进制文件并将其添加到PATH来推进这一点。 但后来我不得不安装谷歌Chrome浏览器 – 单独ChromeDriver不足以运行testing。 所以错误是terminal窗口中的屏幕缓冲区的问题,但你可以安装虚拟屏幕缓冲区的Xvfb。 重要的是,您应该以root身份运行testing,因为您可能会收到另一个Chrome浏览器浏览器错误。 所以没有根我运行:

 export DISPLAY=:99 Xvfb :99 -ac -screen 0 1280x1024x24 & 

这里重要的是,在我的情况下,与DISPLAY相关的数字应该与Xvfb:NN参数相同。 在这种情况下99。 我有另一个问题,因为我用另一个DISPLAY值运行Xvfb,我希望它停止。 为了重新启动Xvfb:

 ps -aux | grep Xvfb kill -9 PID sudo rm /tmp/.X11-unix/X99 

所以find一个带有grep的进程PID。 杀死Xvfb进程。 然后锁在/tmp/.X11-unix/XNN,所以删除这个锁,你可以重新启动服务器。 如果你不是以root身份运行,请设置simillar显示,然后安装google-chrome然后用maven启动seleniumtesting。 这些规则和操作我的testing都很顺利。

我正在运行一个类似的设置:Selenium 3.40,Chrome 61,chromedriver 2.33在ubuntu 16.04上用xvfb运行。

我间歇性地收到了相同的Chrome错误。 似乎有时候,chromedriver无法清理与Chromeconfiguration文件关联的临时文件。

对我来说一个解决方法是在运行testing之前清理临时文件:

 rm -rf /tmp/.org.chromium.Chromium* 

我预计这将在未来的版本的chromedriver解决,但现在这解决了我的情况下的问题。