gulp-angular-protractor icon indicating copy to clipboard operation
gulp-angular-protractor copied to clipboard

When a test fails, the stand alone web driver process is not shut down

Open jesperoastrom opened this issue 11 years ago • 3 comments

In our project we want to run all e2e tests, create a report and show it to the developer with all the successful and failed tests. We find this gulp task super useful but we are having trouble with one thing. When any test fails, the web driver process does not get terminated and the gulp task never ends. To mitigate this we're using this hack: Sample gulpfile.js

var gulp = require('gulp');
var angularProtractor = require('gulp-angular-protractor');

gulp.task('run-e2e', function(callback){

    /* Hack to get gulp-angular-protractor to terminate the web driver process even if a test fails */
    var webDriver = require('../node_modules/gulp-angular-protractor/gulp-angular-protractor/web-driver.js');

    gulp.src(['./e2e/**/*.feature'])
        .pipe(angularProtractor({
            'configFile': 'protractor.config.js',
            'args': ['--baseUrl', baseUrl],
            'autoStartStopServer': true
        }))
        .on('error', function (e) {
            /* Use same url as in config */
            webDriver.webDriverStandaloneStop('http://localhost:4444/wd/hub', callback);
        })
        .on('end', function () {
            callback();
        });
});

gulp.task('create-e2e-report', ['run-e2e'], function() {/* omitted */});
gulp.task('open-e2e-report', ['create-e2e-report'], function() {/* omitted */});

Looking at the source (gulp-stream.js line 63) it looks like this is by design so there might be a use case that I don't understand. Would it be possible to always stop the web driver process, even if exit code > 0, or will that cause other issues?

Thanks for the great work!

Regards

Jesper

jesperoastrom avatar Nov 04 '15 20:11 jesperoastrom

I am having a different weddriver issue. Not sure, could turn out to be a misconfiguration on my part... I have chromedriver setup globally on my dev machine but while trying to run the tests; I get the following error:

        throw new Error('Could not find chromedriver at ' +
        ^

Error: Could not find chromedriver at .../node_modules/protractor/selenium/chromedriver.exe
    at LocalDriverProvider.addDefaultBinaryLocs_ (.../node_modules/protractor/lib/driverProviders/local.dp.js:42:15)
    at LocalDriverProvider.setupEnv (.../node_modules/protractor/lib/driverProviders/local.dp.js:59:8)
    at Runner.run (.../node_modules/protractor/lib/runner.js:335:31)
    at process.<anonymous> (.../node_modules/protractor/lib/runFromLauncher.js:32:14)
    at emitTwo (events.js:87:13)
    at process.emit (events.js:172:7)
    at handleMessage (internal/child_process.js:686:10)
    at Pipe.channel.onread (internal/child_process.js:440:11)
[launcher] Runner Process Exited With Error Code: 1
[13:08:40] gulp-angular-protractor - Webdriver standalone server is stopped

I can run protractor on same directory with any issues. A hack would be to copy all requirements (chromedriver?) to the folder it's expecting it but I don't think that would scale... Did you encounter same problems? @jesperoastrom

Bernard.

ojengwa avatar Nov 06 '15 12:11 ojengwa

@jesperoastrom

I don't remember this case: probably when "autoStartAndStop" had to be manage into the gulp-stream.js ?

I will fix it

Many thanks for your feedback

rochejul avatar Nov 06 '15 15:11 rochejul

@ojengwa

Can your create a separated issue with a concret example (a zip file with your configuration)

Many thanks!

rochejul avatar Nov 06 '15 15:11 rochejul