Visual Regression for V5
We are pleased to announce that we now have a new Visual Regression service for WebdriverIO V5 called wdio-image-comparison-service
.
#
What can it do?wdio-image-comparison-service is a lightweight WebdriverIO service for browsers / mobile browsers / hybrid apps to do image comparison on screens, elements or full page screens.
You can:
- save or compare screens / elements / full page screens against a baseline
- automatically create a baseline when no baseline is there
- blockout custom regions and even automatically exclude a status and or tool bars (mobile only) during a comparison
- increase the element dimensions screenshots
- use different comparison methods
- and much more, see the options here
The module is now based on the power of the new webdriver-image-comparison
module. This is a lightweight module to retrieve the needed data and screenshots for all browsers / devices.
The comparison power comes from ResembleJS. If you want to compare images online you can check the online tool.
It can be used for:
- desktop browsers (Chrome / Firefox / Safari / Internet Explorer 11 / Microsoft Edge)
- mobile / tablet browsers (Chrome / Safari on emulators / real devices) via Appium
- Hybrid apps via Appium
For versions check below:
#
InstallationInstall this module locally with the following command to be used as a (dev-)dependency:
Instructions on how to install WebdriverIO
can be found here.
#
Usagewdio-image-comparison-service supports NodeJS 8 or higher
#
Configurationwdio-image-comparison-service
is a service so it can be used as a normal service. You can set it up in your wdio.conf.js
file with the following:
More plugin options can be found here.
#
Writing testswdio-image-comparison-service is framework agnostic, meaning that you can use it with all the frameworks WebdriverIO supports like Jasmine|Mocha
.
You can use it like this:
If you run for the first time without having a baseline the check
-methods will reject the promise with the following warning:
This means that the current screenshot is saved in the actual folder and you manually need to copy it to your baseline.
If you instantiate wdio-image-comparison-service
with autoSaveBaseline: true
the image will automatically be saved into the baseline folder.
#
Nice new featureWhen you create a fullpage screenshot you might have some elements that stay in the view, like a stickyheader or a chatbox. These elements normally mess up the screenshot like you can see on the left side of the below image.
But you can now add elements that need to be hidden after the first scroll which will give you a result as you can see in the right side of the below image. This can be done by adding this property to your test:
#
Test result outputsThe save(Screen/Element/FullPageScreen)
methods will provide the following information after the method has been executed:
See the Save output section in the output docs for the images.
By default the check(Screen/Element/FullPageScreen)
methods will only provide a mismatch percentage like 1.23
, but when the plugin has the options returnAllCompareData: true
the following information is provided after the method has been executed:
See the Check output on failure section in the output docs for the images.
#
SupportIf you need support you can find me on the wdio-image-comparison-service
- Gitter channel, or click on this link
Happy testing!
Grtz,
The Blue Guy