0

I have done everything as written on https://www.npmjs.com/package/protractor-html-screenshot-reporter, but no HTML or screenshots are saved to folder.

I've installed protractor-html-screenshot-reporter with command:

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

I have then done npm init and saved package.json file, which contains:

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

I can also see protractor-html-screenshot-reporter in /node_modules/ folder.

In config file I have the following:

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

Now when I run protractor conf.js I don't see any /reports/screenshots folder, HTML report or screenshot created. Help please!

jurijk
  • 309
  • 8
  • 22

1 Answers1

1

Jasmine allure Reporter is better for reports and screenshots

Below is the code for it:

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

I Hope this solves your problem. Visit the Link for more information.

Kishan Patel
  • 1,385
  • 3
  • 13
  • 24
  • Thanks for the tip. I have installed it, but the problem I get is the same as with protractor-html-screenshot-reporter, meaning that no XML or screenshot is created. What bothers me that no error is reported once conf.js file is started, even if I change `var AllureReporter = require('jasmine-allure-reporter');` to `var AllureReporter = require('jasmine-allureX-reporter');`. – jurijk Mar 02 '17 at 13:22
  • I am using it daily brother. It should work. Can you send share your test file also along with conf.js . A folder named 'allure-results' must be created or else change resultDir to D:/Allure-results. – Kishan Patel Mar 02 '17 at 13:25
  • Lucky you and unlucky me ;) I have also used the full path, like `var AllureReporter = require('/home/lxuser/node_modules/jasmine-allure-reporter');` with no changes. Is there also something I should write in my test spec file? I'm using Linux. – jurijk Mar 02 '17 at 13:33
  • Jasmine-allureX-reporter ? I am having Jasmine-allure-reporter. Please check. – Kishan Patel Mar 02 '17 at 13:34
  • I copy pasted, sorry about that. I do have `var AllureReporter = require('/home/lxuser/node_modules/jasmine-allure-reporter')‌​;` and no allure-results folder is created along with XML and screenshots. – jurijk Mar 02 '17 at 13:35
  • One more thing, just to confirm, jasmine2 frameworks should be set in conf.js file, right? – jurijk Mar 02 '17 at 13:37
  • I'm saying as you have used absolute path for this , use the same for you resultdirectory under onprepare method i.e. resultsDir : ' your absolute path/ allure-results' . I hope I'm clear – Kishan Patel Mar 02 '17 at 13:39
  • Yes put jasmine2 as well – Kishan Patel Mar 02 '17 at 13:39
  • Still nothing. I have used absolute paths with no avail: `var AllureReporter = require('/home/lxuser/node_modules/jasmine-allure-reporter');var reporter = new AllureReporter({ allureReport:{ resultsDir: '/home/lxuser/allure-results' } }); jasmine.getEnv().addReporter(reporter); jasmine.getEnv().topSuite().afterEach({fn: function(){ browser.takeScreenshot().then(function (png) { reporter.createAttachment('Screenshot', function () { return new Buffer(png, 'base64') }, 'image/png')(); }) }});` – jurijk Mar 02 '17 at 14:03
  • I also found this: http://stackoverflow.com/questions/35967224/allure-reports-are-not-generated-in-protractor. – jurijk Mar 02 '17 at 14:07
  • Let me have a look – Kishan Patel Mar 02 '17 at 14:11
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/137067/discussion-between-kishan-patel-and-jurijk). – Kishan Patel Mar 02 '17 at 14:17