Created
July 8, 2013 22:49
-
-
Save micalexander/5953146 to your computer and use it in GitHub Desktop.
phantomjs:casperjs:take multiple screenshots of different urls (dependencies: xcode, homebrew, phantomjs, casperjs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // // Usage : casperjs filename.js | |
| // // Size of the browser i.e. viewport | |
| var view_width = 1024, view_height = 672; | |
| // // Size of the clipped image | |
| var clip_width = 1024, clip_height = 672; | |
| var casper = require("casper").create({ | |
| // // Set the viewport size | |
| viewportSize: {width: view_width, height: view_height}, | |
| // // Set the position and the size of the clipped image | |
| clipRect: { | |
| top: 0, | |
| left: 0, | |
| width: clip_width, | |
| height: clip_height | |
| } | |
| }); | |
| // // Take screenshots of these sites | |
| var links = [ | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/here/', | |
| 'http://insert/url/heret/' | |
| ]; | |
| casper.start(); | |
| var i = 0; | |
| casper.each(links, function(self, link) { | |
| this.thenOpen(link, function() { | |
| i++; | |
| // // Output to console on the current page's title | |
| this.echo(i + ' : ' + this.getTitle() + " @ " + link); | |
| // // Dump screenshots to directory 'shots' | |
| this.capture('shots/file_name' + i + '.png'); | |
| }); | |
| }); | |
| casper.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment