Sign inSign up

kohkimakimoto/nightmare

By kohkimakimoto

•Updated almost 10 years ago

Nightmare headless container.

Image
1

367

kohkimakimoto/nightmare repository overview

⁠docker-nightmare

Nightmare⁠ headless container.

⁠Example

Add a shell function to use it conveniently.

nightmare() {
    docker run -v $PWD:/mnt/work -w /mnt/work --rm -e "cmd=$NIGHTMARE_CMD" kohkimakimoto/nightmare:latest "$@";
    return $?;
}

Create screenshot.js.

var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: false });

nightmare
  .goto("https://google.com")
  .evaluate(() => {
    const body = document.querySelector('body');

    return {
      height: body.scrollHeight,
      width: body.scrollWidth
    };
  })
  .then(function(dimensions) {
    return nightmare
      .viewport(dimensions.width, dimensions.height)
      .wait(1000)
      .screenshot(require('path').join(__dirname, 'screenshot.png'))
  })
  .then(function() {
    nightmare.end(function() {
      console.log('done');
    });
  });

Run screenshot.js

$ nightmare screenshot.js

You will get the screenshot.png file.

Tag summary

Content type

Image

Digest

Size

506.3 MB

Last updated

almost 10 years ago

docker pull kohkimakimoto/nightmare