urls.js
1.3 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
/*global casper*/
/*jshint strict:false*/
casper.test.begin('urls tests', 6, function(test) {
casper.start('tests/site/urls.html', function() {
this.clickLabel('raw unicode', 'a');
});
casper.then(function() {
test.assertHttpStatus(200);
test.assertUrlMatches('Forlì', 'Casper.getCurrentUrl() retrieves a raw unicode URL');
this.clickLabel('escaped', 'a');
});
casper.then(function() {
test.assertHttpStatus(200);
test.assertUrlMatches('Forlì', 'Casper.getCurrentUrl() retrieves an escaped URL');
this.clickLabel('uri encoded', 'a');
});
casper.run(function() {
test.assertHttpStatus(200);
test.assertUrlMatches('Forlì', 'Casper.getCurrentUrl() retrieves a decoded URL');
test.done();
});
});
// https://github.com/n1k0/casperjs/issues/841
casper.test.begin('url tests with javascript disabled', 1, function(test) {
casper.options.pageSettings.javascriptEnabled = false;
casper.start('tests/site/urls.html');
casper.then(function() {
test.assertMatch(this.getCurrentUrl(), /urls\.html$/,
'Casper.getCurrentUrl() can work, with javascript disabled');
});
casper.run(function() {
test.done();
casper.options.pageSettings.javascriptEnabled = true;
});
});