Chromedriver手动工作但从Jenkins Slave运行时失败

时间:2016-05-10 18:40:56

标签: linux selenium jenkins protractor selenium-chromedriver

我使用LinuxMint设置了Jenkins从属节点。因此,我们可以在Chrome和Firefox的Linux机器上进行一些浏览器测试。

我安装了最新的Chromedriver,测试可以运行它,当我手动进入/var/jenkins/workspace/<project name>/TestAutomation/SeleniumFramework并执行run npm <test name>测试时,启动chromedriver并成功运行。

当我进入Jenkins并且运行我的测试时,chromedriver失败了以下内容并且我不知道该去哪里。:

  

直接使用ChromeDriver ...   [launcher]运行WebDriver的1个实例   /var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/atoms/error.js:108     var template = new Error(this.message);                    ^   UnknownError:未知错误:Chrome无法启动:异常退出     (驱动程序信息:chromedriver = 2.21.371461(633e689b520b25f3e264a2ede6b74ccc23cb636a),platform = Linux 3.19.0-32-generic x86_64)       at new bot.Error(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/atoms/error.js:108:18)       at Object.bot.response.checkResponse(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/atoms/response.js:109:9)       at /var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:160:24       at promise.ControlFlow.runInFrame_(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20)       at goog.defineClass.notify(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25)       at promise.Promise.notify_(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12)       at Array.forEach(native)       at promise.Promise.notifyAll_(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15)       at goog.async.run.processWorkQueue(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/async/run.js:130:15)       at process._tickCallback(internal / process / next_tick.js:103:7)   来自:任务:WebDriver.createSession()       在Function.webdriver.WebDriver.acquireSession_(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)       在Function.webdriver.WebDriver.createSession(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)       在新的驱动程序(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/chrome.js:810:36)       在DirectDriverProvider.getNewDriver(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/protractor/lib/driverProviders/direct.js:68:16)       在Runner.createBrowser(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/protractor/lib/runner.js:182:37)       at /var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/protractor/lib/runner.js:263:21       在_fulfilled(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:797:54)       at self.promiseDispatch.done(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:826:30)       在Promise.promise.promiseDispatch(/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:759:13)       at /var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:525:49   [launcher]进程已退出,错误代码为1

2 个答案:

答案 0 :(得分:2)

第一个解决方案:

你安装了java 8吗?如果是,请将其卸载并安装java 7。

第二个解决方案:

将量角器降级到v1.8.0

更多信息: https://github.com/angular/protractor/issues/1905

@edit

我在jenkins中发现了一个类似的主题,同样的错误 - linux:

In you jenkins settings add a global property

key : DISPLAY
value:0:0

On your server start Xvfb in the background:

Xvfb :0 -ac -screen 0 1024x768x24 &

link:unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9

答案 1 :(得分:2)

所以我通过SSH连接到Jenkins大师的奴隶。这不会启动浏览器会话。我切换到了Java Web Start选项,它启动了浏览器就好了。