multirun.js
1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var casper, check, countLinks, currentSuite, suites;
casper = require("casper").create({
verbose: true
});
countLinks = function() {
return document.querySelectorAll('a').length;
};
suites = [
function() {
this.echo("Suite 1");
this.start("http://google.com/", function() {
this.echo("Page title: " + (this.getTitle()));
});
this.then(function() {
this.echo((this.evaluate(countLinks)) + " links");
});
}, function() {
this.echo("Suite 2");
this.start("http://yahoo.com/", function() {
this.echo("Page title: " + (this.getTitle()));
});
this.then(function() {
this.echo((this.evaluate(countLinks)) + " links");
});
}, function() {
this.echo("Suite 3");
this.start("http://bing.com/", function() {
this.echo("Page title: " + (this.getTitle()));
});
this.then(function() {
this.echo((this.evaluate(countLinks)) + " links");
});
}
];
casper.start();
casper.then(function() {
this.echo("Starting");
});
currentSuite = 0;
check = function() {
if (suites[currentSuite]) {
suites[currentSuite].call(this);
currentSuite++;
casper.run(check);
} else {
this.echo("All done.");
this.exit();
}
};
casper.run(check);