I am using protractor for the first time and doesn't know how to add custom screenshots to jasmine report. Currently i am have done some thing like this.
onPrepare:
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
takeScreenshots: true,
takeScreenshotsOnlyOnFailures: false,
consolidate: true,
consolidateAll: true,
filePrefix: 'Report',
screenshotsPath: './screenshots/',
reportPath: './pageObject/reports/'
})
);
And added the code to take the screenshot.
browser.takeScreenshot().then(function (png) {
test.writeScreenShot(png,screenshotName+ '.png');
});
test.writeScreenShot = function(data,filepath){
var stream = fs.createWriteStream(path);
stream.write(new Buffer(data, 'base64'));
stream.end();
};
But now the actual pain comes in, it takes the snapshot of entire page and attach in report which i doesn't want and i want the custom snapshot which i have taken only for specific element and attach it in jasmine report. I couldn't understand how the snapshot is added to the report . can some help me how the snapshot is added automatically to the report so that i can try once for the custom snapshot taken by me and try adding it to the report.
Thanks in advance.
答案 0 :(得分:0)
就我所知,硒本身不支持制作某个区域的屏幕截图。您只能制作可见页面的屏幕截图。
如果您正在努力使用屏幕截图,请查看https://github.com/azachar/protractor-screenshoter-plugin (免责声明:我是分叉的作者)
您可以针对每个期望制作屏幕截图。此外,它还附带一个基于HTML的报告,因此很容易理解为什么测试失败。