Skip to content

Instantly share code, notes, and snippets.

@ypresto
Created December 16, 2012 13:24
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 ypresto/4307223 to your computer and use it in GitHub Desktop.
Save ypresto/4307223 to your computer and use it in GitHub Desktop.
Example for integrate test with casperjs
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="hoge"><a href="#!/hoge">clickable hoge</a></div>
<div id="fuga" style="width:0px"><a href="#!/fuga">unclickable fuga</a></div>
</body>
</html>
/*global require:false */
var casper = require('casper').create();
casper.start('./casper_test.html');
casper.then(function () {
this.test.assertVisible('#hoge', 'hoge is clickable');
this.clickLabel('clickable hoge');
});
casper.then(function () {
this.test.assertUrlMatch(/#!\/hoge/, 'hash changed to hoge');
});
casper.then(function () {
this.test.assertNotVisible('#fuga', 'fuga is not clickable');
this.clickLabel('unclickable fuga');
});
casper.then(function () {
this.test.assertUrlMatch(/#!\/hoge/, 'hash not changed to fuga');
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment