protractor-html-screenshot-reporter不起作用

时间:2017-03-02 12:09:07

标签: html protractor report screenshot

我完成了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
        }));
   }
}

现在,当我运行量角器conf.js时,我没有看到任何/ reports / screenshots文件夹,HTML报告或截图创建。求救!

1 个答案:

答案 0 :(得分: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();
        });
      });
      }

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