A WebdriverIO plugin. Additional commands for taking screenshots with WebdriverIO.
Install wdio-screenshot via NPM as usual:
$ npm install wdio-screenshot --save-dev
Instructions on how to install WebdriverIO
can be found here.
Note: If you want to improve performance, you can install GraphicsMagick.
Setup wdio-screenshot by adding a wdio-screenshot
key to the plugins section of your WebdriverIO config.
// wdio.conf.js
exports.config = {
// ...
plugins: {
'wdio-screenshot': {}
},
// ...
};
wdio-screenshot enhances an WebdriverIO instance with the following commands:
browser.saveViewportScreenshot([fileName], [{options}]);
browser.saveDocumentScreenshot([fileName], [{options}]);
browser.saveElementScreenshot([fileName], elementSelector, [{options}]);
All of these provide options that will help you to exclude unrelevant parts (e.g. content). The following options are available:
-
exclude
String[]|Object[]
(not yet implemented)
exclude frequently changing parts of your screenshot, you can either pass all kinds of different WebdriverIO selector strategies that queries one or multiple elements or you can define x and y values which stretch a rectangle or polygon -
hide
String[]
hides all elements queried by all kinds of different WebdriverIO selector strategies (viaopacity: 0
) -
remove
String[]
removes all elements queried by all kinds of different WebdriverIO selector strategies (viadisplay: none
)
wdio-screenshot uses GraphicsMagick for image processing when available. Without GraphicsMagick installed, wdio-screenshot fallbacks to Jimp - a image processing library written in JS.
If you want to install GraphicsMagick, follow the instructions below.
Mac OS X using Homebrew
$ brew install graphicsmagick
$ sudo apt-get install graphicsmagick
Download and install executables for GraphicsMagick. Please make sure you install the right binaries desired for your system (32bit vs 64bit).
MIT