Skip to content

👻 📷 A Nightmare plugin to easily take screenshots.

License

Notifications You must be signed in to change notification settings

Leelow/nightmare-screenshot-selector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nightmare-screenshot-selector

npm version NPM downloads Build Status Build Status JavaScript Style Guide

A Nightmare plugin to easily take screenshots. https://github.com/segmentio/nightmare

Install

$ npm install --save nightmare-screenshot-selector

Usage

const Nightmare = require('nightmare');
const screenshotSelector = require('nightmare-screenshot-selector');
const fs = require('fs')

Nightmare.action('screenshotSelector', screenshotSelector)

var nightmare = Nightmare()
nightmare
        .goto('https://example.com/')
        .screenshotSelector('h1') // get the image in a buffer
        .then(function (data) {
          fs.writeFileSync('screen.png', data)
        })
        
nightmare
        .goto('https://example.com/')
        .screenshotSelector({selector: 'h1', path:'screen.png'}) // create directly a file
        .end()

Test

You just have to clone the repo and run

$ npm test

License

MIT © Léo Lozach

Releases

No releases published

Packages

No packages published