samnissen / watir-screenshot-stitch

Extends Watir to take full page screenshots of websites.
MIT License
17 stars 7 forks source link

base64_canvas screenshots doesn't include cross domain images #28

Closed sandeepnagra closed 6 years ago

sandeepnagra commented 6 years ago

I have a fix for it but it works in all browsers except Firefox and IE.

Chrome, Edge, Safari works like a charm. The fix is in my fork for your review @samnissen - https://github.com/sandeepnagra/watir-screenshot-stitch/blob/master/lib/watir-screenshot-stitch.rb

All I did is upgrade the html2canvas.js file and replace a deprecated option onrendered with new .then option.

I am trying to find a fix for Firefox & IE as well but I haven't had any good luck with it yet. Will keep searching and if I find a fix for those two browsers, I will add it and then raise a PR.

samnissen commented 6 years ago

@sandeepnagra Were you able to determine what the error was with Firefox and/or IE? I assume its something with the implementation of html2canvas.js ? I could theoretically let Firefox use version 0.5.x and Chrome use v 1.x until there is a stable cross-platform...

sandeepnagra commented 6 years ago

@samnissen - I have reported a bug with html2canvas project for this issue - https://github.com/niklasvh/html2canvas/issues/1476

Once they fix it for Firefox and IE, I will raise a PR for the fix I have in my fork.

samnissen commented 6 years ago

@sandeepnagra I implemented code to switch between the latest htmlcanvas with onrendered and and the current version with the current JavaScript, and the screenshots I took of Mass Mutual's site are identical. Do you have any other sites that exhibit this behavior that I can test this against?

sandeepnagra commented 6 years ago

@samnissen - when you say identical, do you mean you still don't see images included? If yes, then look at my PR and update the javascript to what I have in my PR and it should work.

samnissen commented 6 years ago

Sorry, I mean that the following all look effectively the same:

I cannot replicate the image you showed once (I can't remember where) of mass Mutual's website with many of the images looking wrong or missing.

sandeepnagra commented 6 years ago

Even I can't find where I shared the screenshots that didn't had images. We had multiple discussions across different tickets. I also raised a PR in #27 and we had discussion in #26 as well. I also reported a bug with html2canvas for the Firefox issue. I remember updating html2canvas version because it was not capturing any image on the webpage.

samnissen commented 6 years ago

Well, many thanks for looking into this anyway. Let me know if you can re-reproduce the bug conditions, and I'll reopen this straight away.

sandeepnagra commented 6 years ago

Hi @samnissen,

I found the scenario for which this issue is reproducible. Try taking a base64_canvas screenshot of this site - https://advisors.massmutual.com/

It will generate a bad/corrupt PNG. Now try the same with the changes I have made in my PR - https://github.com/sandeepnagra/watir-screenshot-stitch and it will render a proper PNG.

samnissen commented 6 years ago

Thanks, I'll reopen this now.

samnissen commented 6 years ago

Fixed by #36