Last active
August 3, 2016 16:37
-
-
Save mrosati84/6038290 to your computer and use it in GitHub Desktop.
Test automation for responsive layout using PhantomJS
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
/* | |
requires: phantomjs, async | |
usage: phantomjs capture.js | |
*/ | |
var async = require('async'), | |
sizes = [ | |
[320, 480], | |
[1024, 768], | |
[1280, 800], | |
[1280, 1024], | |
[1440, 900], | |
[1920, 1080] | |
]; | |
function capture(sizes, callback) { | |
var page = require('webpage').create(); | |
page.viewportSize = { | |
width: sizes[0], | |
height: sizes[1] | |
}; | |
page.zoomFactor = 1; | |
page.open('http://localhost.youtsite.com/', function (status) { | |
var filename = sizes[0] + 'x' + sizes[1] + '.png'; | |
page.render('./screenshots/' + filename); | |
page.close(); | |
callback.apply(); | |
}); | |
} | |
async.eachSeries(sizes, capture, function (e) { | |
if (e) console.log(e); | |
console.log('done!'); | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment