E2E Testing with Protractor
- Protractor is an end-to-end test framework for AngularJS applications
- It execute tests against your application running in a real browser, interacting with it as a real life user.
- Make sure you have updated version of webdriver-manager otherwise execute below command in cmd before executing gulp task
webdriver-manager update --standalone
- In protractor.config.js file mention file path to the selenium server jar, path of chrome driver and comment out address of a running selenium server before executing gulp task
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.48.2.jar',
chromeDriver: './node_modules/protractor/selenium/chromedriver.exe',
//seleniumAddress: 'http://localhost:4444/wd/hub',
- Start webdriver-manager in seperate console before executing gulp task
webdriver-manager start
- __dirname is global object of NodeJS for the name of the directory that the currently executing script resides in
Pre Install:
npm install --save-dev gulp
Install:
npm install --save-dev gulp-protractor protractor
Code:
var gulp = require('gulp');
var protractor = require("gulp-protractor").protractor;
gulp.task('e2e', function (done) {
gulp.src(__dirname + './protractor_test/')
.pipe(protractor({
configFile: './protractor.config.js',
args: ['--baseUrl', 'http://127.0.0.1:8000']
}))
.on('error', function (e) { throw e })
});
Execute:
gulp e2e