seleniumselenium-webdriverprotractorgulp-protractor

Gulp-protractor not starting webdriver-manager


I'm trying to run protractor automatically using gulp-protractor plugin. This whole process works fine when using protractor commands and explicitly running the web drivers individually. The same works when running using gulp-protractor, provided ie webdriver is started manually in background before triggering the gulp task.

Below is the code snippet of my Gulp task

var protractor = require("gulp-protractor").protractor;
var webdriverupdate = require("gulp-protractor").webdriver_update;;
var webdriver_standalone = require("gulp-protractor").webdriver_standalone;

// This task is to update  & run the webdriver
gulp.task('webdriver_standalone', webdriver_standalone);
gulp.task('webdriverUpdate', ['webdriver_standalone'], function () {
  browsers: ['chrome', 'ie']
});

//for running protractor E2E test cases
gulp.task('protractor', function (callback) {
gulp
    .src(['./e2e/sanity/shared/*.spec.ts',
            './e2e/sanity/app-header/*.spec.ts',
            ])
    .pipe(protractor({
        'configFile': 'Protractor.conf.js',
    }))
    .on('error', function (e) {
        console.log(e);
    })
    .on('end', callback);
  });

gulp.task('default',['webdriverUpdate','protractor']);

Below is the code snippet of my protractor.config.js

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
allScriptsTimeout: 1100,
suites: {
    shared: ['./e2e/sanity/shared/*.ts'] ,
    appheader: ['./e2e/sanity/app-header/*.spec.ts']
},
    multiCapabilities: 
    [{
          seleniumAddress: 'http://localhost:5555/',
          'browserName': 'internet explorer',            
          'platform': 'windows 10',
          'version': '11',
          'ignoreProtectedModeSettings': true,
    },
    { 
         seleniumAddress: 'http://localhost:4444/wd/hub',
        'browserName': 'chrome',
        'ignoreProtectedModeSettings': true,
}],
};

How do I run webdriver standalone task ahead of protractor task via gulp??


Solution

  • I used gulp with gulp-angular-protractor like below, hope this helps. It will work for gulp-protractor plugin as well.

    //Gulpfile

    var gulp = require('gulp');
    var gulpProtractor = require('gulp-angular-protractor');
    var paths = require('../paths.js');
    
    // Execute e2e Tests
     gulp.task('e2e-test', function(callback) {
         gulp.src(paths.tests)
             .pipe((gulpProtractor({
                     configFile: 'protractor.conf.js'
             })).on('error', function(e) {
                     console.log(e);
                 }).on('end', callback));
     });
    
    
    gulp.task('webdriver-update', gulpProtractor.webdriver_update);
    gulp.task('webdriver-standalone', ['webdriver-update'], gulpProtractor.webdriver_standalone);
    

    //paths.js:

    module.exports = {
        tests: 'test/e2e/**/*.spec.js'
    };