在多浏览器环境中的Nightwatch.js测试循环测试

时间:2015-10-08 10:54:42

标签: node.js selenium nightwatch.js

您好我有以下简单的夜间游戏演示脚本,当使用多个浏览器环境运行时循环播放,但如果我使用单个浏览器运行测试,工作正常。< / p>

以下参数循环测试:

        var argv = {
            test: 'nightwatchgoogletest.js',
            config: 'nightwatch.json',
            reporter: 'junit',
            env : 'default,chrome'
        };

以下工作正常:

        var argv = {
            test: 'nightwatchgoogletest.js',
            config: 'nightwatch.json',
            reporter: 'junit',
            env : 'chrome' (or default or any single browser)
        };

以下是我的代码,请让我知道我在这里做错了什么。

nightwatchgoogletest.js

module.exports = {
  
  'Demo test Google' : function (client) {
    client
      .url('http://google.no')
      .pause(1000);

    // expect element  to be present in 1000ms
    client.expect.element('body').to.be.present.before(1000);

    // expect element <#lst-ib> to have css property 'display'
    client.expect.element('#lst-ib').to.have.css('display');

    // expect element  to have attribute 'class' which contains text 'vasq'
    client.expect.element('body').to.have.attribute('class').which.contains('vasq');

    // expect element <#lst-ib> to be an input tag
    client.expect.element('#lst-ib').to.be.an('input');

    // expect element <#lst-ib> to be visible
    client.expect.element('#lst-ib').to.be.visible;

    client.end();
  }
};

并编写了以下节点脚本来调用上面的测试:

var Nightwatch = require('nightwatch');

function proceess_test() {
    try {
        var argv = {
            test: 'nightwatchgoogletest.js',
            config: 'nightwatch.json',
            reporter: 'junit',
            env : 'default,chrome'
        };

        console.log("\n>> Initiating Tests for ...",process.env.__NIGHTWATCH_ENV_KEY);
        var settings = {};
        var done = function() {console.log("done")};
        Nightwatch.runner(argv, done, settings);
        done();
    } catch (error) {
        console.log('Exception: ' + error.message);
    }
}

proceess_test();

使用以下夜间配置配置: http://www.jsoneditoronline.org/?id=7e8e1616d595417ceeafaccc6358b33d

但是当我运行测试时,它会进入无限测试循环,如下所示:

nightwatch looping the test nightwatch looping the test

0 个答案:

没有答案