fetchtext.js
1.7 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
/*eslint strict:0*/
casper.test.begin('fetchText() basic tests', 1, function(test) {
casper.start('tests/site/index.html', function() {
test.assertEquals(this.fetchText('ul li'), 'onetwothree',
'Casper.fetchText() can retrieve text contents');
}).run(function() {
test.done();
});
});
casper.test.begin('fetchText() basic tests', 1, function(test) {
casper.start('tests/site/index.html', function() {
test.assertEquals(this.fetchText('input[name="dummy_name"]'), 'dummy_value',
'Casper.fetchText() can retrieve text contents from an input element');
}).run(function() {
test.done();
});
});
casper.test.begin('fetchText() handles HTML entities', 1, function(test) {
casper.start().then(function() {
this.setContent('<html><body>Voilà</body></html>');
test.assertEquals(this.fetchText('body'), 'Voilà',
'Casper.fetchText() fetches decoded text');
});
casper.run(function() {
test.done();
});
});
casper.test.begin('fetchText() handles empty elements', 1, function(test) {
casper.start().then(function() {
this.setContent('<html><body></body></html>');
test.assertEquals(this.fetchText('body'), '',
'Casper.fetchText() fetches empty string');
});
casper.run(function() {
test.done();
});
});
casper.test.begin('fetchText() handles plain texts', 1, function(test) {
casper.start().then(function() {
this.setContent('This is a plain text.');
test.assertEquals(this.fetchText('html'), 'This is a plain text.',
'Casper.fetchText() handles plain texts');
});
casper.run(function() {
test.done();
});
});