我正在一个angularjs项目中工作,我用量角器构建测试。我想用Jenkins自动化我的测试。我写了一个小的shell脚本来启动我的测试,它在我的终端上运行良好。但是当我尝试从Jenkins启动脚本时,我遇到了一个问题。在jenkins控制台中,我可以看到此错误消息:
Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/test
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
[test] $ /bin/sh -xe /tmp/hudson2254278298273314957.sh
+ sh /home/test/Desktop/jenkins.sh
[4mRunning "connect:server" (connect) task[24m
[4mRunning "protractor:chrome" (protractor) task[24m
Waiting forever...
Started connect web server on http://localhost:3001
Using ChromeDriver directly...
[launcher] Running 1 instances of WebDriver
等等...... 10秒
/home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:108
var template = new Error(this.message);
^
UnknownError: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.23.409687 (c46e862757edc04c06b1bd88724d15a5807b84d1),platform=Linux 4.4.0-21-generic x86_64)
at new bot.Error (/home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:108:18)
at Object.bot.response.checkResponse (/home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:109:9)
at /home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:160:24
at [object Object].promise.ControlFlow.runInFrame_ (/home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20)
at [object Object].goog.defineClass.notify (/home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25)
at [object Object].promise.Promise.notify_ (/home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12)
at Array.forEach (native)
at [object Object].promise.Promise.notifyAll_ (/home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15)
at goog.async.run.processWorkQueue (/home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/async/run.js:130:15)
at process._tickCallback (node.js:368:9)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at new Driver (/home/test/workspace/frontend/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:810:36)
at [object Object].DirectDriverProvider.getNewDriver (/home/test/workspace/frontend/node_modules/protractor/lib/driverProviders/direct.js:68:16)
at [object Object].Runner.createBrowser (/home/test/workspace/frontend/node_modules/protractor/lib/runner.js:182:37)
at /home/test/workspace/frontend/node_modules/protractor/lib/runner.js:263:21
at _fulfilled (/home/test/workspace/frontend/node_modules/protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/home/test/workspace/frontend/node_modules/protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/home/test/workspace/frontend/node_modules/protractor/node_modules/q/q.js:759:13)
at /home/test/workspace/frontend/node_modules/protractor/node_modules/q/q.js:525:49
at flush (/home/test/workspace/frontend/node_modules/protractor/node_modules/q/q.js:108:17)
at nextTickCallbackWith0Args (node.js:419:9)
at process._tickCallback (node.js:348:13)
at Function.Module.runMain (module.js:444:11)
at startup (node.js:136:18)
at node.js:966:3
[launcher] Process exited with error code 1
[31m>> [39m
[33mWarning: Tests failed, protractor exited with code: 1 [4mUsed --force, continuing.[24m[39m
[31mDone, but with warnings.[39m
Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information
Finished: SUCCESS
由于这个问题,我完全被阻止了。你有什么线索可以解决这个问题吗? 感谢y'所有!
答案 0 :(得分:0)
根据该错误,您的配置中似乎有directConnect: true
。 Jenkins无法直接连接到浏览器驱动程序,因此请删除该行。
你也在使用localhost
,也不认为詹金斯可以使用它。您可能需要远程selenium服务器。
这是一篇关于针对Windows VM运行Protractor的博客文章(它专注于针对Internet Explorer运行,但提供了围绕整个过程的大量有用信息)http://elgalu.github.io/2014/run-protractor-against-internet-explorer-vm/
答案 1 :(得分:0)
UnknownError:未知错误:Chrome无法启动:异常退出
可能是因为很多情况。 只需确保,jenkins slave有一些显示(真实或虚拟)。一般来说,jenkins奴隶没有真正的显示器,因此我们必须启动一些虚拟显示器,如xvfb,以便使selenium工作。如果selenium没有找到任何虚拟显示,chrome会抱怨同样的错误:无法启动。
但也有许多其他原因。