Skip to content

Instantly share code, notes, and snippets.

@ebrehault
Created February 4, 2014 15:19
Show Gist options
  • Save ebrehault/8805622 to your computer and use it in GitHub Desktop.
Save ebrehault/8805622 to your computer and use it in GitHub Desktop.
a sample CasperJS test generated using Resurrectio
//==============================================================================
// Casper generated Tue Feb 04 2014 16:17:45 GMT+0100 (CET)
//==============================================================================
var x = require('casper').selectXPath;
casper.options.viewportSize = {width: 1855, height: 993};
casper.test.begin('Resurrectio test', function(test) {
casper.start('http://en.wikipedia.org/wiki/Main_Page');
casper.waitForSelector(x("//*[contains(text(), \'Welcome\')]"),
function success() {
test.assertExists(x("//*[contains(text(), \'Welcome\')]"));
},
function fail() {
test.assertExists(x("//*[contains(text(), \'Welcome\')]"));
});
casper.waitForSelector("input[name='search']",
function success() {
this.sendKeys("input[name='search']", "javascript");
},
function fail() {
test.assertExists("input[name='search']");
});
casper.waitForSelector("#searchButton img",
function success() {
test.assertExists("#searchButton img");
this.click("#searchButton img");
},
function fail() {
test.assertExists("#searchButton img");
});
casper.then(function() {
test.assertUrlMatch(/^http:\/\/en.wikipedia.org\/wiki\/Javascript$/);
});
casper.wait(1000);
casper.then(function() {
this.captureSelector("screenshot1.png", "html");
});
casper.run(function() {test.done();});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment