I've got 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 must work on Windows.
I've got 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 must work on Windows.
I've been working with Behat for awhile now and it's certainly isn't as popular as it should be. There's not that many popular plugins from any team other than Behat's, and there's definitely no well-known / well-supported plugin for Behat to compare images. In fact that would be true for PHP as well, except for the GD and Imagic, which have a much broader scope.
Besides, the logic isn't very clear what and how you'd compare. Screenshots are normally taken on failure. Comparing two screenshots of failed tests doesn't make much sense, only comparing screenshots of failed tests against screenshots of relevant tests that passed before. The questions is then where and how would you get those valid screenshots, and the whole chain of other questions coming from here.
That sounds like a very specific challenge and I'm certain only a limited group of users would need something like that, probably with a lot of logic unique and specific to their case. On another hand, implementing basic image comparison in PHP isn't that difficult, given you have the basic skills working with graphics in PHP.
One thing that comes to mind is Imagick::compareImages
, see the official documentation. There also seem to be plenty of blog posts, like this one or this one, which show different ways of doing that.