Skip to content

Instantly share code, notes, and snippets.

@juneym
Forked from gaspanik/capture.js
Created January 9, 2016 07:08
Show Gist options
  • Save juneym/42e1dc7ed6b2d340b644 to your computer and use it in GitHub Desktop.
Save juneym/42e1dc7ed6b2d340b644 to your computer and use it in GitHub Desktop.
Take screenshot at single viewport size using CasperJS
var screenshotUrl = 'http://example.com/'
var casper = require("casper").create({
viewportSize: {
width: 1024,
height: 768
}
});
if (casper.cli.args.length < 1) {
casper
.echo("Usage: $ casperjs capture.js http://example.com")
.exit(1)
;
} else {
screenshotUrl = casper.cli.args[0];
}
casper.start(screenshotUrl, function() {
this.capture('example.png', {
top: 0,
left: 0,
width: 1024,
height: 768
});
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment