我试着从詹金斯那里运行我的protractor程序,但是由于詹金斯没有显示器,我需要在无头模式下运行chrome。因为chrome没有无头模式,所以我需要使用xvfb模拟显示。
我学习了很多教程,但是当我运行“量角器”时,chrome崩溃了。
以下是我所拥有的:
构建-执行shell(在jenkins作业中)

#emulate display
echo "Starting xvfb on :99..."
Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99

echo "Checking that xvfb started ok..."
xdpyinfo -display :99 >/dev/null 2>&1 && echo "xvfb is using :99" || echo "xvfb is not using :99, it's free."

#now start my program
xvfb-run -a --server-args='-screen 0, 1024x768x16' protractor conf.js

下面是我的输出:
+ echo Starting xvfb on :99...
Starting xvfb on :99...
+ export DISPLAY=:99
+ echo Checking that xvfb started ok...
Checking that xvfb started ok...
+ xdpyinfo -display :99
+ Xvfb -ac :99 -screen 0 1280x1024x16
+ echo xvfb is using :99
xvfb is using :99

[22:26:25] I/local - Starting selenium standalone server...
[22:26:25] I/launcher - Running 1 instances of WebDriver
[22:26:26] I/local - Selenium standalone server started at http://10.0.0.82:54385/wd/hub
[22:27:26] E/launcher - unknown error: Chrome failed to start: crashed
  (Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.16 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'ip-10-0-0-82', ip: '10.0.0.82', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
[22:27:26] E/launcher - WebDriverError: unknown error: Chrome failed to start: crashed
  (Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.16 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'ip-10-0-0-82', ip: '10.0.0.82', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
    at WebDriverError (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/error.js:27:5)
    at Object.checkLegacyResponse (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/error.js:639:15)
    at parseHttpResponse (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/http/index.js:538:13)
    at client_.send.then.response (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/http/index.js:472:11)
    at ManagedPromise.invokeCallback_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:1379:14)
    at TaskQueue.execute_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2913:14)
    at TaskQueue.executeNext_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2896:21)
    at asyncRun (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2820:25)
    at /jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:639:7
    at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
    at Function.createSession (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
    at Builder.build (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/builder.js:458:24)
    at Local.DriverProvider.getNewDriver (/jenkins/workspace/myjob/src/js/node_modules/protractor/built/driverProviders/driverProvider.js:37:33)
    at Runner.createBrowser (/jenkins/workspace/myjob/src/js/node_modules/protractor/built/runner.js:198:43)
    at /jenkins/workspace/myjob/src/js/node_modules/protractor/built/runner.js:277:30
    at _fulfilled (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:796:13)
    at /jenkins/workspace/myjob/src/js/node_modules/q/q.js:604:44
    at runSingle (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:137:13)
[22:27:26] E/launcher - Process exited with error code 199

我试过的每一件事都让我觉得…这是我如何启动或配置xvfb的问题吗?还是我的量角器代码有问题?stacktrace根本帮不了我。

最佳答案

我建议使用Jenkins Xvfb Plugin。它的工作非常好,而不必过多地干扰配置。
要设置作业,只需单击xvfb选项在作业开始时运行,并在作业结束时关闭xvfb。一旦设置好了,就可以在不使用xvfb的情况下执行量角器命令:protractor conf.js

关于linux - 如何使用Xvfb在带有chrome的Jenkins上无角度运行 Protractor ?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40666341/

10-12 03:22