Skip to content

Extend Nightmare to improve screenshot with selector

Notifications You must be signed in to change notification settings

koshuang/nightmare-screenshoter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nightmare-screenshoter

Extend Nightmare to improve screenshot with selector.

.screenshotSelector(path, selector)

Saves a screenshot of the element which matches the specified selector to the specified path.

Example

const Nightmare = require('nightmare');
const installPlugin = require('nightmare-screenshoter').installPlugin;

installPlugin(Nightmare);

const screenshotPath = path.join(process.cwd(), 'test.png');
new Nightmare()
  .goto('http://example.com')
  .screenshotSelector('test.png', 'h1')
  .then(() => {
    const stats = fs.statSync(screenshotPath);
    if (stats.isFile()) {
      console.log('DONE');
    }
  });

About

Extend Nightmare to improve screenshot with selector

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%