【问题标题】:protractor-jasmine2-screenshot-reporter creates report but with result as '0' and no screenshotsprotractor-jasmine2-screenshot-reporter 创建报告但结果为“0”且没有屏幕截图
【发布时间】:2018-05-18 02:42:18
【问题描述】:

我一直在尝试使用“protractor-jasmine2-screenshot-reporter”获取我的执行结果的 html 报告和屏幕截图,但 HTML 报告的内容类似于

报告

总结

测试的总规格:0

失败总数:0

并且没有截图保存在该位置。

此处为 HTML 报告截图

我的配置文件如下

    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);
    }
   };

其他详情如下: 量角器@3.2.2, 节点版本:4.2.4, npmVersion:2.14.12, 茉莉花:2.4.1, selenium-webdriver: 2.52.0

任何人都可以建议我任何解决方案吗?

【问题讨论】:

  • 找不到您的规格,请检查您的规格路径!
  • 感谢您的回复。 “检查规范的路径”是什么意思?你能告诉我文件夹结构应该是什么吗?
  • 我的conf和spec文件的文件夹结构是:User/My_folder/npm-global/lib/node_modules/protractor/FFAutomation,在FFAutomation里面我有我所有的spec文件和conf文件。 “protractor-jasmine2-screenshot-reporter”的文件夹结构是:User/My_folder/node_modules。我的目标文件夹是在 FFAutomation 文件夹中创建的。我需要改变什么吗?请提出建议。
  • 所以你的规范文件和你的配置文件在同一个文件夹中?
  • 尝试将您的规范配置更改为 > 规范:['./Login_spec3.js']

标签: protractor


【解决方案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);
    })
}
};

我在我的系统中对其进行了测试,它运行良好;)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多