Skip to content

Instantly share code, notes, and snippets.

@florinel-chis
Created August 21, 2013 10:27
Show Gist options
  • Select an option

  • Save florinel-chis/6292830 to your computer and use it in GitHub Desktop.

Select an option

Save florinel-chis/6292830 to your computer and use it in GitHub Desktop.
Sample CasperJS test to check if a div identified by a class (".col-main") is present.
/**
* Test if a div with the class .col-main is present on homepage
*/
console.log('checking cli options');
var casper_cli = require("casper").create();
if(!casper_cli.cli.options.url){
console.log("--url=domain.com missing");
casper_cli.exit();
}
casper.test.begin('Looking at the homepage now', 1, function suite(test) {
//load up the login page and make sure it loads properly
casper.start("http://"+casper.cli.options.url+'/', function() {
console.log("Loading "+casper.cli.options.url);
test.assertExists('div.col-main','Main column is found');
});
casper.run(function() {
test.done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment