Skip to content

Instantly share code, notes, and snippets.

@ulrich
Created April 7, 2013 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulrich/5331182 to your computer and use it in GitHub Desktop.
Save ulrich/5331182 to your computer and use it in GitHub Desktop.
This Gist is a dummy CasperJS test with the grails-casper-plugin configuration .
var casper = require('casper').create();
casper.start('http://www.google.fr/', function () {
this.test.assertTitle('Google', 'google homepage title is the one expected');
this.test.assertExists('form[action="/search"]', 'main form is found');
this.fill('form[action="/search"]', {
q: 'foo'
}, true);
});
casper.then(function () {
this.test.assertTitle('foo - Recherche Google', 'google title is ok');
this.test.assertUrlMatch(/q=foo/, 'search term has been submitted');
this.test.assertEval(function () {
return __utils__.findAll('h3.r').length >= 10;
}, 'google search for "foo" retrieves 10 or more results');
});
casper.run(function () {
this.test.done(5); // checks that 5 assertions have been executed
this.test.renderResults(true, 0, this.cli.get('xunitFileName'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment