Protractor-html-screenshot-reporter does not show report after test execution

I am using protractor to automate a hybrid mobile app, I am using tracer-html-screenshot relayer, but after a successful test, it doesn't display any report.

Here is my code below:

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

var reporter=new HtmlReporter({
        baseDirectory: 'C:\\Users\\bhawani.prasad\\Desktop\\Protractor\\PageObject\\report', // a location to store screen shots.
        docTitle: 'Protractor Demo Reporter',
        docName:    'protractor-demo-tests-report.html'
    });


 onPrepare: function() {
        jasmine.getEnv().addReporter(reporter);
        } ,

      

+3


source to share


2 answers


For those wondering why there are no screenshots generated protactor-html-screenshot-reporter

and, if you are using jasmine2

:

protractor-html-screenshot-reporter is not compatible with jasmine 2



Switch to protractor-jasmine2-screenshot-reporter

.

+4


source


There isn't much here. I would recommend that you just screen the screenshot library and roll your own. Here we use internally to capture screenshot and html after a failed test.

function setupScreenGrabber() {
   jasmine.getEnv().afterEach(function() {
        if (jasmine.getEnv().currentSpec.results_.failedCount > 0) {
            var filename = 'target/screenshots/failed-' + jasmine.getEnv().currentSpec.getFullName() + '-' + Date.now();
            browser.takeScreenshot().then(function(png) {
                var stream = fs.createWriteStream(filename + '.png');
                stream.write(new Buffer(png, 'base64'));
                stream.end();
            });
            element(by.css('html')).getOuterHtml().then(function(html) {
                fs.writeFile(filename + '.html', html);
            });
        }
    });
}

      



Just call this method from onPrepare

. You need require(fs)

. Also, since you only want to capture when passing tests, change > 0

to === 0

. But that should get you started.

0


source







All Articles