Skip to content

Instantly share code, notes, and snippets.

@chris-gunawardena
Created May 21, 2014 02:11
Show Gist options
  • Save chris-gunawardena/800da3d59fbce985a779 to your computer and use it in GitHub Desktop.
Save chris-gunawardena/800da3d59fbce985a779 to your computer and use it in GitHub Desktop.
var phantomcss = require('./../phantomcss.js');
phantomcss.init();
casper.start();
casper.viewport(1024, 768);
var tests = [
function(casper, phantomcss) {
casper.echo("Suite 1");
casper.start("http://google.com/", function() {
casper.echo("Page title: " + (casper.getTitle()));
});
casper.then(function() {
casper.waitForSelector('body',
function success(){
casper.echo((casper.getTitle()) + " - taking screenshot");
phantomcss.screenshot('body', (casper.getTitle()) + " - taking screenshot");
},
function timeout(){
casper.test.fail('Timeout');
}
);
});
}, function(casper, phantomcss) {
casper.echo("Suite 2");
casper.start("http://yahoo.com/", function() {
casper.echo("Page title: " + (casper.getTitle()));
});
casper.then(function() {
casper.waitForSelector('body',
function success(){
casper.echo((casper.getTitle()) + " - taking screenshot");
phantomcss.screenshot('body', (casper.getTitle()) + " - taking screenshot");
},
function timeout(){
casper.test.fail('Timeout');
}
);
});
}
];
for(var i=0; i<tests.length; i++ )
{ tests[i](casper, phantomcss)
}
casper.then( function now_check_the_screenshots(){
// compare screenshots
phantomcss.compareAll();
});
casper.then( function end_it(){
casper.test.done();
});
/*
Casper runs tests
*/
casper.run(function(){
console.log('\nTHE END.');
phantom.exit(phantomcss.getExitStatus());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment