Javascript 量角器+;黄瓜;吞咽量角器=测试失败时,浏览器不会关闭

Javascript 量角器+;黄瓜;吞咽量角器=测试失败时,浏览器不会关闭,javascript,selenium,cucumber,protractor,gulp-protractor,Javascript,Selenium,Cucumber,Protractor,Gulp Protractor,你好 当测试失败后,我试图关闭浏览器,目前,当测试通过时,浏览器确实会关闭 我正在使用 "cucumber": "^0.9.2", "gulp": "~3.9.0", "gulp-protractor": "^2.1.0", "protractor": "3.0.0", "protractor-cucumber-framework": "^0.3.2", "selenium-standalone": "4.8.0", $ node --version v5.3.0 $ npm --versio

你好

当测试失败后,我试图关闭浏览器,目前,当测试通过时,浏览器确实会关闭

我正在使用

"cucumber": "^0.9.2",
"gulp": "~3.9.0",
"gulp-protractor": "^2.1.0",
"protractor": "3.0.0",
"protractor-cucumber-framework": "^0.3.2",
"selenium-standalone": "4.8.0",

$ node --version
v5.3.0
$ npm --version
3.5.2
我的吞咽量角器看起来像:

/**
 * run protractor
 */


var args = require('yargs').argv;


module.exports = function(gulp, plugins) {
    return function (done) {
        var protractorConfig = '',
            testConfig = '',
            environment = args.environment || 'devel',
            tag = args.tag || '@Sanity',
            baseUrl;

        if (!args.baseUrl) {
            baseUrl = 'http://test.me/frontend-build-tests/';
        } else if (args.baseUrl.match(/^(?:https?\:)?\/\//)) {
            baseUrl = args.baseUrl;
        } else {
            baseUrl = 'http://test.me/frontend-build-tests/' + args.baseUrl + '/';
        }

        switch(environment) {
            case 'devel' :
                protractorConfig = 'e2e/protractor.config.devel.js';
                testConfig = '../config/devel';
            break;
            case 'live'  :
                protractorConfig = 'e2e/protractor.config.live.js';
                testConfig = '../config/live';
            break;
            case 'remote' :
                protractorConfig = 'e2e/protractor.config.remote.js';
                testConfig = '../config/live';
            break;
            default:
            case 'build' :
                protractorConfig = 'e2e/protractor.config.build.js';
                testConfig = '../config/build';
            break;
        }

        gulp.src([
            'e2e/features/*.feature'
        ])
        .pipe(plugins.protractor.protractor({
            configFile: protractorConfig,
            args: [
                '--verbose',
                '--no-stackTrace',
                '--params.test.config', testConfig,
                '--baseUrl', baseUrl,
                '--cucumberOpts.tags', tag
            ]
        }))
        //.on('end', function(){
        //        console.log('E2E Testing complete');
        //        process.exit();
        //    })
        .on('error', function() {
            done();
                //protractor.driver.quit();
                process.exit(1);
                //var protractor = require("gulp-protractor").protractor;
                //console.log("ON Error");
                //protractor.browser.quit();
                //throw e;

            });
    };
};
this.Then(/^I see that the slider has moved/, function (done) {
    browser.sleep(500);
    sliderWidgetPage.getImageAndAttribute(0,'data-url').then(function (attrVal) {
        expect(attrAtX1Time).to.eventually.not.be.equal(attrVal);

    });
    done();
});
而我的
量角器.config
具有:

exports.config = {
    //seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.47.1.jar',
    seleniumAddress: 'http://localhost:4444/wd/hub',
    //directConnect: true,//To run test directly against Chrome/FFs
    specs: [
        'e2e/features/*.feature'
    ],
    multiCapabilities: [
        {
            'browserName': 'chrome',
            'chromeOptions': {
                'args': ['show-fps-counter=true','enable-logging','v=1','net-log-level=0']
            }
        },
        // {
        //   'browserName': 'firefox'
        // },
        // {
        //   'browserName': 'safari'
        // },
        // {
        //   'browserName': 'phantomjs',
        //   'phantomjs.binary.path':'./node_modules/phantomjs/bin/phantomjs',
        //   'phantomjs.cli.args':'--debug=true --loglevel=DEBUG --webdriver --webdriver-loglevel=DEBUG'
        // }
    ],
    framework: 'custom',
    frameworkPath: require.resolve('protractor-cucumber-framework'),
    cucumberOpts: {
        require: 'features/step_definitions/**/*.js',
        format: 'json'
        //tags: "@Sanity"

    },

    resultJsonOutputFile: 'report.json',
    //count: 2,
    //shardTestFiles: true,
    //maxInstances:2,

    onPrepare: function () {

        browser.getCapabilities().then(function (capabilities) {
            browser.capabilities = capabilities;
        });
        browser.driver.manage().window().maximize();

        browser.ignoreSynchronization = true; //This is set for non-Angular apps

        browser.manage().timeouts().implicitlyWait(20000);


    }
    //,
    //onCleanUp: function(exitCode) {
    //    if (exitCode ==1){
    //        console.log("Getting out");
    //        browser.quit();
    //    };
    //},
};
测试失败,浏览器保持打开状态,这会导致CI服务器内存泄漏!我要怎么做才能解决这个问题

请帮忙

编辑 我的失败步骤如下所示:

/**
 * run protractor
 */


var args = require('yargs').argv;


module.exports = function(gulp, plugins) {
    return function (done) {
        var protractorConfig = '',
            testConfig = '',
            environment = args.environment || 'devel',
            tag = args.tag || '@Sanity',
            baseUrl;

        if (!args.baseUrl) {
            baseUrl = 'http://test.me/frontend-build-tests/';
        } else if (args.baseUrl.match(/^(?:https?\:)?\/\//)) {
            baseUrl = args.baseUrl;
        } else {
            baseUrl = 'http://test.me/frontend-build-tests/' + args.baseUrl + '/';
        }

        switch(environment) {
            case 'devel' :
                protractorConfig = 'e2e/protractor.config.devel.js';
                testConfig = '../config/devel';
            break;
            case 'live'  :
                protractorConfig = 'e2e/protractor.config.live.js';
                testConfig = '../config/live';
            break;
            case 'remote' :
                protractorConfig = 'e2e/protractor.config.remote.js';
                testConfig = '../config/live';
            break;
            default:
            case 'build' :
                protractorConfig = 'e2e/protractor.config.build.js';
                testConfig = '../config/build';
            break;
        }

        gulp.src([
            'e2e/features/*.feature'
        ])
        .pipe(plugins.protractor.protractor({
            configFile: protractorConfig,
            args: [
                '--verbose',
                '--no-stackTrace',
                '--params.test.config', testConfig,
                '--baseUrl', baseUrl,
                '--cucumberOpts.tags', tag
            ]
        }))
        //.on('end', function(){
        //        console.log('E2E Testing complete');
        //        process.exit();
        //    })
        .on('error', function() {
            done();
                //protractor.driver.quit();
                process.exit(1);
                //var protractor = require("gulp-protractor").protractor;
                //console.log("ON Error");
                //protractor.browser.quit();
                //throw e;

            });
    };
};
this.Then(/^I see that the slider has moved/, function (done) {
    browser.sleep(500);
    sliderWidgetPage.getImageAndAttribute(0,'data-url').then(function (attrVal) {
        expect(attrAtX1Time).to.eventually.not.be.equal(attrVal);

    });
    done();
});

也许你需要写得像

.be.equal(attrVal).notify(done)

是的,除此之外,我还必须添加以下内容:`this.setDefaultTimeout(100*1000);`因为我得到了一个超时,你认为这种方法有什么问题吗?谢谢