Behat on Windows - taking screenshots

I have several Behat tests that take screenshots using something similar to this:

$driver->getWebDriverSession()->screenshot();

      

Does anyone know of a Behat plugin or extension that can compare two screenshots? And it should work on Windows.

+3


source to share


2 answers


What you are looking for is the pdiff extension: for windows it looks something like this: http://seleniumrecipes.com/content/using-perceptual-difference-pdiff-tool

Screenshots are definitely not "taken on failure only" - you can of course take a basic set of screenshots and use a tool like https://github.com/jadu/BehatPerceptualDiffExtension to fail the test if the perceived difference in perception is different (i.e. if the css change has outdone in an unexpected way).



This fork ( https://github.com/ksenzee/BehatPerceptualDiffExtension/commits/master ) PerceptualDiffExtention adds the concept of diff masks - that is, regions that you want to ignore, for example, if you had some kind of slideshow, the screenshot may show a glitch because the random starting slide is different.

Also, the author recently gave a conversation about using differences of perception with Behat: http://2014.pnwdrupalsummit.org/pacific-nw-drupal-summit-2014/sessions/deploying-confidence-automated-visual-regression-and , so there is some slides that you could use as a resource.

+1


source


I have been working with Behat for a long time now and it is definitely not as popular as it should be. There aren't many popular plugins out there from any team other than Behat's, and there is definitely no known / well-supported Behat plugin for comparing images. This is actually true for PHP as well, with the exception of GD and Imagic, which have much wider coverage.

In addition, the logic is not entirely clear what and how you will compare. Screenshots are usually taken on failure. Comparing two screenshots of failed tests doesn't make much sense, just comparing screenshots of failed tests with screenshots of corresponding tests that were previously passed. The question then becomes where and how will you get these valid screenshots, as well as a whole chain of other questions coming from here.



This sounds like a very daunting task, and I'm sure only a limited group of users will require something like this, probably with a lot of logic unique and specific to their case. On the other hand, implementing basic image comparison in PHP is not that difficult since you have basic graphics skills in PHP.

One thing that comes to mind is Imagick::compareImages

, see the official documentation . There also seems to be a lot of blog posts like this one or this that show different ways of doing this.

0


source







All Articles