Files
zulip/zephyr/tests/frontend/casperjs/samples/extends.js
Tim Abbott eadb2ea6d3 Update casperjs to 1.0.2.
(imported from commit 9e34b51c4588dce6419ea86024b2e8c06346a685)
2013-03-05 15:10:32 -05:00

41 lines
838 B
JavaScript

/*jshint strict:false*/
/*global CasperError console phantom require*/
var casper = require("casper").create({
loadImages: false,
logLevel: "debug",
verbose: true
});
var links = {
"http://edition.cnn.com/": 0,
"http://www.nytimes.com/": 0,
"http://www.bbc.co.uk/": 0,
"http://www.guardian.co.uk/": 0
};
var fantomas = Object.create(casper);
fantomas.countLinks = function() {
return this.evaluate(function() {
return __utils__.findAll("a[href]").length;
});
};
fantomas.renderJSON = function(what) {
this.echo(JSON.stringify(what, null, " "));
};
fantomas.start();
Object.keys(links).forEach(function(url) {
fantomas.thenOpen(url, function() {
links[url] = this.countLinks();
});
});
fantomas.run(function() {
this.renderJSON(links);
this.exit();
});