Headless protractor tests don't plug on Xvfb

感情迁移 提交于 2019-12-25 05:06:04

问题




I'm trying to run Protractor tests both in command line and with Jenkins. Both fail with the same error.

Command line

  • I opened a prompt and launched webdriver-manager start
  • In another prompt, I launched Xvfb :42 -ac -screen 0 1024x768x24 &
  • In a third one, I eventually launched protractor myconf.js

Jenkins

  • In my build, I checked "Start Xvfb before the build, and shut it down after.".
  • I run the tests in a shell script.

    sh 'sudo webdriver-manager clean'
    sh 'sudo webdriver-manager update'
    sh 'xvfb-run webdriver-manager start --seleniumPort 9094 &'
    checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'tests']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'myprettycredentials', url: 'myprettyproject.git']]])
    sh 'sudo sudo chmod -R a+rwx tests'
    sh 'sudo killall Xvfb'
    sh 'export DISPLAY=:43'
    sh 'sudo Xvfb :43 -ac -screen 0 1024x768x24 &'
    wrap([$class: 'Xvfb']) {
    sh 'sudo protractor tests/src/conf-demo.js --troubleshoot'
    }

In both cases, I get this error.

Failed: unknown error: an X display is required for keycode conversions,
consider using Xvfb

Why won't my tests plug on the Xvfb I started for them so zealously? Thanks for your help.


回答1:


Alright, I finally managed to run my Protractor tests headlessly using

xvfb-run -a webdriver-manager start --seleniumPort 9094 &
protractor myconf.js

Where -a chooses any free display, and & makes the task run in background.




回答2:


Great to hear you resolve your issue.

Another alternative would be to create a gulp task and use the gulp-angular-protractor extension. I think is easier to configure and run.

And install the xvfb plugin to use it on the configuration on your job.

Good Luck !



来源:https://stackoverflow.com/questions/44150844/headless-protractor-tests-dont-plug-on-xvfb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!