Socket
Socket
Sign inDemoInstall

wdio-screenshot-v7

Package Overview
Dependencies
315
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    wdio-screenshot-v7

Screenshot commands for WebdriverIO 7


Version published
Weekly downloads
102
increased by17.24%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

wdio-screenshot-v7

A WebdriverIO plugin. Additional commands for taking screenshots with WebdriverIO.

Working properly with WebdriverIO > 7.0.0. This is based on the updated v5 port https://github.com/mondata-dev/wdio-screenshot-v5, which in turn is based on https://github.com/mjdch/wdio-screenshot-v5 and originally https://github.com/zinserjan/wdio-screenshot.

Browser Support

  • Firefox

  • Chrome

  • Safari / Opera / etc - not tested

Installation

Install wdio-screenshot via NPM as usual:

$ npm install wdio-screenshot-v5 --save-dev

Instructions on how to install WebdriverIO can be found here.

Note: If you want to improve performance, you can install GraphicsMagick.

Configuration

Setup wdio-screenshot by adding a wdio-screenshot key to the service section of your WebdriverIO config. More information Custom Services

const WdioScreenshot = require('wdio-screenshot-v5');

// wdio.conf.js
exports.config = {
  // ...
  services: [..., [WdioScreenshot]]
  // ...
};

Usage

wdio-screenshot enhances an WebdriverIO instance with the following commands:

  • browser.saveViewportScreenshot([fileName], [{options}]);
  • browser.saveDocumentScreenshot([fileName], [{options}]);
  • browser.saveElementScreenshot([fileName], elementOrSelector, [{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[] | Element[]
    hides all elements queried by all kinds of different WebdriverIO selector strategies (via opacity: 0)

  • remove String[] | Element[]
    removes all elements queried by all kinds of different WebdriverIO selector strategies (via display: none)

Use GraphicsMagick

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
Ubuntu using apt-get
$ sudo apt-get install graphicsmagick
Windows

Download and install executables for GraphicsMagick. Please make sure you install the right binaries desired for your system (32bit vs 64bit).

License

MIT


1 Scaling of iOS Simulator has to be 100% for properly recorded screenshots (see here)

2 iOS scales the zoom level to fit the website into the viewport when the width of your page is bigger than the viewport. Capturing screenshots of such scaled websites with iOS is experimental and error-prone. If you notice any errors, adjust your viewport settings in your meta tag to disable scaling with <meta name="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">

FAQs

Last updated on 24 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc