Created
June 1, 2015 09:46
-
-
Save rbg246/0ecc8d747af9ec2438d7 to your computer and use it in GitHub Desktop.
CasperJS Test File - iterating through a Data Object specifying multiple viewports for each page
This file contains 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
module.exports = { | |
clientScripts : [ | |
'./node_modules/jquery/dist/jquery.min.js', | |
'./node_modules/lodash/index.js' | |
], | |
viewportSize : { | |
width: 1600, | |
height: 1200 | |
}, | |
timeout : 50000, | |
// verbose: true, | |
// logLevel: 'debug' | |
}; |
This file contains 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
{ | |
"name": "casper-tests", | |
"version": "0.0.0", | |
"description": "", | |
"main": "start.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Richard Gaunt", | |
"license": "ISC", | |
"dependencies": { | |
"jquery": "^2.1.4", | |
"lodash" : "*", | |
"spooky": "^0.2.5" | |
} | |
} |
This file contains 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
var defaultViewports = [ | |
{ | |
width : 320, | |
height : 480 | |
}, | |
{ | |
width: 1024, | |
height: 768 | |
}, | |
{ | |
width: 1600, | |
height: 1200 | |
} | |
]; | |
module.exports = [ | |
{ | |
url : 'http://www.richardgaunt.com', | |
viewports : defaultViewports | |
}, | |
{ | |
url :'http://www.alfresco.com', | |
viewports : defaultViewports | |
} | |
]; |
This file contains 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
var config = require('./config'); | |
var pages = require('./pageData'); | |
var casper = require('casper').create(config); | |
casper.start(); | |
casper.eachThen(pages, function (response) { | |
var url = response.data.url; | |
var viewports = response.data.viewports; | |
casper.eachThen(viewports, function (res) { | |
var viewport = res.data; | |
casper.thenOpen(url, function (response) { | |
console.log(url + ' - ' + viewport.width + 'x' + viewport.height); | |
}); | |
}); | |
}); | |
casper.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment