alert.js
1.05 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
/*global casper*/
/*jshint strict:false*/
casper.test.begin('alert events', 1, {
ok: false,
tearDown: function(test) {
casper.removeAllListeners('remote.alert');
},
test: function(test) {
var self = this;
casper.once('remote.alert', function(message) {
self.ok = (message === 'plop');
});
casper.start('tests/site/alert.html', function() {
test.assert(self.ok, 'alert event has been intercepted');
});
casper.run(function() {
test.done();
});
}
});
casper.test.begin("Casper.waitForAlert() waits for an alert", 1, function(test) {
casper.start().then(function() {
this.evaluate(function() {
setTimeout(function() {
alert("plop");
}, 500);
});
});
casper.waitForAlert(function(response) {
test.assertEquals(response.data, "plop",
"Casper.waitForAlert() can wait for an alert to be triggered");
});
casper.run(function() {
test.done();
});
});