Protractor testing, up and running.

Grunt — Express — Protractor

protractor is a end-to-end testing framework meant for angularJS UI testing. In another words, this is an automated testing framework.

Let us see how you can setup the protractor.

1. Install node.js

You can download and install node.js from here.

2. Install grunt plug-ins
npm install grunt-express-server --save-dev
npm install grunt-protractor-runner --save-dev
npm install grunt-protractor-webdriver --save-dev
3. Configure grunt file.
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks(‘grunt-protractor-runner’);
grunt.loadNpmTasks(‘grunt-protractor-webdriver’);
grunt.initConfig({
express: { //express server
'protractor-test': {
options: {
script: 'server.js', //eg. nodeJS server script serving your webpp, running on port say 3000 or you can configure entirely on express
port: 3001
}
}
},
protractor_webdriver: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
}
},

protractor: {
options: {
// Default config file
configFile: "node_modules/protractor/example/conf.js",
// If false, the grunt process stops when the test fails.
keepAlive: true,
// If true, protractor will not use colors in its output.
       noColor: false, 
args: {
// Arguments passed to the command
}
},
all: {
// Grunt requires at least one target to run so you can simply put 'all: {}' here too.
options: {
configFile: "spec/custom-conf.js", // Target-specific config file
args: {} // Target-specific arguments
}
}
}
});
});
4. custom-conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs:['e2e/webpapp-page1_test.js'] // where you write e2e tests
};
5. protractor runs, on selenium webdriver, hence, It is always better to update your webdriver .
webapp> ./node_modules/protractor/bin/webdriver-manager update --standalone --chrome
6. Run
grunt protractor-test
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.