I am writing automation test scripts using Protractor and now I need to set up the CI for this using Jenkins.
Tasks it needs to perform are:
- Starting the selenium standalon server.
- Starting the test using conf.js file.
- Stopping the selenium standalone server.
Can anyone help in this regard?
The newest protractor allows you to run the selenium standalone server directly from the conf.js (or whatever protractor entry point you have).
comment out (or delete) the
seleniumAddress: 'http://localhost:4444/wd/hub',
line, and replace it withseleniumServerJar: './node_modules/protractor/selenium/latest.jar',
.latest.jar
isn't installed by default, I created it as a symlink to the latest version installed vianpm install protractor --save
. This gives longer life to myconf.js
files in the same directory. Within the./node_modules/protractor/selenium/
folder I ranln -s selenium-server-standalone-2.48.2.jar latest.jar
Alternatively, you could run this as a Grunt Task. First install grunt on Jenkins. Install the NPM packages for protractor_webdriver and protractor. Setup the configuration file to point the the node_module path and config file paths.
http://sideroad.secret.jp/articles/grunt-on-jenkins/
Then install protractor node modules. The Gruntfile would look similar to this. I created a test directory where the conf and spec files would be located.
I created a small bash script to do this.
This script is invoked from a free-style project in jenkins (
Build > Execute shell)
Then the test result report is generated by reading the protractor test results. Hence, you have to produce junit reports from protractor, (look here) :
To make the report visible in jenkins i add a post build action in the job:
Publish JUnit test result report
:You can use Gulp which is far simpler.
After installing gulp in Jenkins System , you may install the npm dependencies(npm install) & run gulp tasks directly as windows batch command in Jenkins as below:
In the background to make selenium server up and running and providing various other parameters , you may use packages like 'gulp-angular-protractor' in the gulpfile.js as below:
gulpfile.js
conf.js
I know this already resolved and want to target for beginner to create Jenkins job and running test. I suggest to use selenium-server-standalone jar in configuration file and call configuration file from Jenkins.
conf.js
Creating Jenkins Job
Install Html Publisher Plugin for end to end testing report
Create Freestyle Project or whatever your needs
Go to Build Section -> Add build step and choose Execute Windows batch command if Jenkins server in Windows otherwise choose Execute Shell for Linux
However you can customize execution command using gulp or similar other packages. Thanks