Created
February 3, 2015 11:57
-
-
Save ronsims2/00641f1379db4b4dfbc5 to your computer and use it in GitHub Desktop.
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
| /******************************************************************************* | |
| * Test using PhantomJS instead of Zombie | |
| * Author: RA Sims II | |
| * Twitter: @mantisOrange | |
| * 01.31.2015 | |
| *******************************************************************************/ | |
| var domain = 'localhost'; | |
| var port = '3000'; | |
| var page = require('webpage').create(); | |
| var referrer = 'http://' + domain + ':' + port + '/quests/super-quests'; | |
| var vigoURL = 'http://' + domain + ':' + port + '/qa/vigo.js'; | |
| var timestamp = new Date(); | |
| timestamp = Math.floor(timestamp.getTime() / 1000); | |
| var clog = function(msg){ | |
| console.log('From phantom page: ' + msg); | |
| }; | |
| page.onConsoleMessage = clog; | |
| page.onAlert = clog; | |
| var snapshot = function(pg, imgName, ext, delay){ | |
| if (delay){ | |
| setTimeout(function(){ | |
| pg.render(imgName + '.' + ext); | |
| }, delay); | |
| } | |
| else { | |
| page.render(imgName + '.' + ext); | |
| } | |
| console.log('Taking snapshot...'); | |
| return true; | |
| }; | |
| page.open(referrer, function(status){ | |
| if (status) { | |
| console.log('Page ' + referrer + ' loaded'); | |
| page.includeJs(vigoURL, function(){ | |
| page.evaluate(function(){ | |
| vigo.config(); | |
| $('.ultraQuests')[0].click(); | |
| }); | |
| }); | |
| snapshot(page, timestamp, 'png', 500); | |
| } | |
| else { | |
| console.log('Phantom could not open page ' + referrer); | |
| phantom.exit(1); | |
| } | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment