wswebcreation / protractor-image-comparison

npm-module to compare images with protractor
86 stars 38 forks source link

how to get path + filename of generated screenshots #62

Closed marcojahn closed 6 years ago

marcojahn commented 6 years ago

Hi,

got the image comparison to work as expected and was able to attach the screenshot to an existing cucumber-html-report.

For the moment (a test case) the path + filename is hard coded. How can I get the name of the generated image ?

Then(/^hat der Bildvergleichstest eine Differenz von maximal "(\d+)" Prozent$/, async function (percent) {
  const imageDiff = await browser.protractorImageComparison.checkScreen('examplePage');

  const img = base64_encode(__dirname + '/../screenshots/actual/diff/examplePage-chrome-1280x1058-dpr-1.png');
  this.attach(img, 'image/png');

  return expect(imageDiff).to.equal(0);
}); 

Aq quick hack could be to change the filename pattern to result in just examplePage-chrome.png...

wswebcreation commented 6 years ago

Hi @marcojahn

I've added a gist with some code of an old project. I hope you understand how I did it. This is the way to attach the difference to the cucumber report file.

https://gist.github.com/wswebcreation/31730968eff3ac654555f64a706409cb

I don't know if it works, but feel free to edit it

Grtz

Wim