multirun.js
1.27 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
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);