【问题标题】:protractor-html-screenshot-reporter does not workprotractor-html-screenshot-reporter 不起作用
【发布时间】:2017-03-07 22:06:56
【问题描述】:

我已按照https://www.npmjs.com/package/protractor-html-screenshot-reporter 上的说明完成所有操作,但没有将 HTML 或屏幕截图保存到文件夹中。

我已经用命令安装了 protractor-html-screenshot-reporter:

npm install protractor-html-screenshot-reporter --save-dev

然后我完成了 npm init 并保存了 package.json 文件,其中包含:

 ...
 "devDependencies": {
    "jasmine-reporters": "^2.2.0",
    "protractor-html-screenshot-reporter": "0.0.21"
  },
 ...

我还可以在 /node_modules/ 文件夹中看到 protractor-html-screenshot-reporter。

在配置文件中我有以下内容:

var HtmlReporter = require('protractor-html-screenshot-reporter');

exports.config = {
    ...

    jasmineNodeOpts: {
        showColors: true, // Use colors in the command line report.
        onComplete: null,
        isVerbose: false,
        includeStackTrace: false,
        defaultTimeoutInterval: 1000000,
        print: function() {}

    },

    onPrepare: function() {
        jasmine.getEnv().addReporter(new HtmlReporter({
            baseDirectory: '../reports/screenshots',
            takeScreenShotsOnlyForFailedSpecs: true,
            docTitle: 'Desk test report',
            docName: 'desk_report.html',
            preserveDirectory: true
        }));
   }
}

现在,当我运行 protractor conf.js 时,我看不到任何 /reports/screenshots 文件夹、HTML 报告或创建的屏幕截图。请帮忙!

【问题讨论】:

  • 嘿,我的回答有帮助吗?

标签: html protractor report screenshot


【解决方案1】:

Jasmine allure Reporter 更适合 reportsscreenshots

下面是它的代码:

//conf.js

exports.config = {
framework: 'jasmine2',  
 jasmineNodeOpts: {
  showColors: true,
  includeStackTrace: true,
  defaultTimeoutInterval: 144000000
 },
directConnect: true,
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['/**/Tests/**/*test.js'],
capabilities: { 'browserName': 'chrome' },

 onPrepare: function () {
    browser.manage().timeouts().implicitlyWait(15000);
    var AllureReporter = require('jasmine-allure-reporter');
    jasmine.getEnv().addReporter(new AllureReporter({
        allureReport: {
            resultsDir: 'allure-results'
        }
    }));
    jasmine.getEnv().afterEach(function (done) {
        browser.takeScreenshot().then(function (png) {
            allure.createAttachment('Screenshot', function () {
                return new Buffer(png, 'base64');
            }, 'image/png')();
            done();
        });
      });
      }

我希望这能解决您的问题。访问链接了解更多信息。

【讨论】:

  • 感谢您的提示。我已经安装了它,但我遇到的问题与 protractor-html-screenshot-reporter 相同,这意味着没有创建 XML 或屏幕截图。让我烦恼的是,一旦启动 conf.js 文件,即使我将 var AllureReporter = require('jasmine-allure-reporter'); 更改为 var AllureReporter = require('jasmine-allureX-reporter');,也不会报告错误。
  • 我每天都在用兄弟。它应该工作。您能否与 conf.js 一起发送共享您的测试文件。必须创建一个名为“allure-results”的文件夹,否则将 resultDir 更改为 D:/Allure-results。
  • 你很幸运,我很不幸;)我也使用了完整的路径,比如var AllureReporter = require('/home/lxuser/node_modules/jasmine-allure-reporter');,没有任何变化。我还应该在我的测试规范文件中写些什么吗?我正在使用 Linux。
  • Jasmine-allureX-reporter ?我有 Jasmine-allure-reporter。请检查。
  • 我复制粘贴了,抱歉。我确实有var AllureReporter = require('/home/lxuser/node_modules/jasmine-allure-reporter')‌​;,并且没有连同 XML 和屏幕截图一起创建 allure-results 文件夹。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-18
相关资源
最近更新 更多