protractor-html-screenshot-reporter not showing any report after test execution

对着背影说爱祢 提交于 2019-12-03 20:40:26

For those who are wondering why there are no screenshots generated by 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.

There's not much to go on here. I'd recommend just ditching a screenshot library and roll your own. Here's what we use internally to grab a 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 inside of onPrepare. You will need to require(fs). Also, since you want to capture only on passing tests, then change > 0 to === 0. But, this should get you started.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!