Commit 100f22a7 100f22a78859b753990927fd95e3f45d14ba69f0 by Nicolas Perriault

added multirun.js code sample

1 parent 04416167
var casper = new phantom.Casper({
verbose: true
});
function countLinks() {
return document.querySelectorAll('a').length;
}
var suites = [
function(self) {
self.echo('Suite 1');
self.start('http://google.com/', function(self) {
self.echo('Page title: ' + self.getTitle());
}).then(function(self) {
self.echo(self.evaluate(countLinks) + ' links');
});
},
function(self) {
self.echo('Suite 2');
self.start('http://yahoo.com/', function(self) {
self.echo('Page title: ' + self.getTitle());
}).then(function(self) {
self.echo(self.evaluate(countLinks) + ' links');
});
},
function(self) {
self.echo('Suite 3');
self.start('http://bing.com/', function(self) {
self.echo('Page title: ' + self.getTitle());
}).then(function(self) {
self.echo(self.evaluate(countLinks) + ' links');
});
}
];
casper.start().then(function(self) {
self.echo('Starting');
});
var currentSuite = 0;
function check(self) {
if (suites[currentSuite]) {
suites[currentSuite](casper);
currentSuite++;
casper.run(check);
} else {
self.echo('All done.').exit();
}
}
casper.run(check);