protractor-jasmine2-screenshot-reporter创建报告但结果为' 0'并且没有屏幕截图

时间:2016-06-22 10:00:24

标签: protractor

我一直在尝试使用" protractor-jasmine2-screenshot-reporter"来获取我的执行结果的html报告和截图。但HTML报告是使用

之类的内容创建的

报告

摘要

测试的总规格:0

总失败:0

此处未保存任何屏幕截图。

HTML报告截图

HTML report screenshot here

我的配置文件如下

    var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
    var reporter = new HtmlScreenshotReporter({
    dest: 'target/screenshots',
    filename: 'my-report.html'
    });
    exports.config = {

    directConnect: true,
    //seleniumAddress: 'http://localhost:4444/wd/hub',
    capabilities: {'browserName': 'chrome'},
    framework: 'jasmine',
    specs: ['Login_spec3.js'],
    allScriptsTimeout: 180000,
    getPageTimeout: 180000,
    jasmineNodeOpts: {
     defaultTimeoutInterval: 180000
    },

   // Setup the report before any tests start
   beforeLaunch: function() {
     return new Promise(function(resolve){
     reporter.beforeLaunch(resolve);
   });
   },

   // Assign the test reporter to each running instance
   onPrepare: function() {
     jasmine.getEnv().addReporter(reporter);
     afterAll(function(done) {
       process.nextTick(done);
     })
   },
    // Close the report after all tests finish
     afterLaunch: function(exitCode) {
       return new Promise(function(resolve){
     reporter.afterLaunch(resolve.bind(this, exitCode));
     });
   },
   onPrepare: function() {
     var width = 1300;
     var height = 1200;
    browser.driver.manage().window().setSize(width,height);
    }
   };

其他详情如下: protractor@3.2.2, nodeVersion:4.2.4, npmVersion:2.14.12, 茉莉:2.4.1, selenium-webdriver:2.52.0

有人可以建议我解决吗?

1 个答案:

答案 0 :(得分:1)

@Sonal:遇到问题,你正在使用2个onPrepare函数,这些函数是冲突的,只使用一个,所以修改后的工作配置将是:

  var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
  var reporter = new HtmlScreenshotReporter({
  dest: 'target/screenshots'
, filename: 'my-report.html'
});
exports.config = {

directConnect: true, //seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
    'browserName': 'chrome'
}
, framework: 'jasmine'
, specs: ['spec.js']
, allScriptsTimeout: 180000
, getPageTimeout: 180000
, jasmineNodeOpts: {
    defaultTimeoutInterval: 180000
},

// Setup the report before any tests start
beforeLaunch: function () {
    return new Promise(function (resolve) {
        reporter.beforeLaunch(resolve);
    });
},

// Close the report after all tests finish
afterLaunch: function (exitCode) {
    return new Promise(function (resolve) {
        reporter.afterLaunch(resolve.bind(this, exitCode));
    });
}
, onPrepare: function () {
    var width = 1300;
    var height = 1200;
    browser.driver.manage().window().setSize(width, height);
    jasmine.getEnv().addReporter(reporter);
    afterAll(function (done) {
        process.nextTick(done);
    })
}
};

我在我的系统中对它进行了测试,结果非常好;)