Commit 2bcc009f 2bcc009ff54e0a8a525df98b07873b22d7b8dbd3 by Nicolas Perriault

migrated xpath tests

1 parent c61f0f18
...@@ -2,33 +2,33 @@ ...@@ -2,33 +2,33 @@
2 /*jshint strict:false*/ 2 /*jshint strict:false*/
3 var x = require('casper').selectXPath; 3 var x = require('casper').selectXPath;
4 4
5 casper.test.comment('XPath'); 5 casper.test.begin('XPath tests', 6, function(test) {
6 6 casper.start('tests/site/index.html', function() {
7 casper.start('tests/site/index.html', function() { 7 test.assertExists({
8 this.test.assertExists({
9 type: 'xpath', 8 type: 'xpath',
10 path: '/html/body/ul/li[2]' 9 path: '/html/body/ul/li[2]'
11 }, 'XPath selector can find an element'); 10 }, 'XPath selector can find an element');
12 this.test.assertDoesntExist({ 11 test.assertDoesntExist({
13 type: 'xpath', 12 type: 'xpath',
14 path: '/html/body/ol/li[2]' 13 path: '/html/body/ol/li[2]'
15 }, 'XPath selector does not retrieve an unexistent element'); 14 }, 'XPath selector does not retrieve an unexistent element');
16 this.test.assertExists(x('/html/body/ul/li[2]'), 'selectXPath() shortcut can find an element as well'); 15 test.assertExists(x('/html/body/ul/li[2]'), 'selectXPath() shortcut can find an element as well');
17 this.test.assertEvalEquals(function() { 16 test.assertEvalEquals(function() {
18 return __utils__.findAll({type: 'xpath', path: '/html/body/ul/li'}).length; 17 return __utils__.findAll({type: 'xpath', path: '/html/body/ul/li'}).length;
19 }, 3, 'Correct number of elements are found'); 18 }, 3, 'Correct number of elements are found');
20 }); 19 });
21 20
22 casper.thenClick(x('/html/body/a[2]'), function() { 21 casper.thenClick(x('/html/body/a[2]'), function() {
23 this.test.assertTitle('CasperJS test form', 'Clicking XPath works as expected'); 22 test.assertTitle('CasperJS test form', 'Clicking XPath works as expected');
24 this.fill(x('/html/body/form'), { 23 this.fill(x('/html/body/form'), {
25 email: 'chuck@norris.com' 24 email: 'chuck@norris.com'
26 }); 25 });
27 this.test.assertEvalEquals(function() { 26 test.assertEvalEquals(function() {
28 return document.querySelector('input[name="email"]').value; 27 return document.querySelector('input[name="email"]').value;
29 }, 'chuck@norris.com', 'Casper.fill() can fill an input[type=text] form field'); 28 }, 'chuck@norris.com', 'Casper.fill() can fill an input[type=text] form field');
30 }); 29 });
31 30
32 casper.run(function() { 31 casper.run(function() {
33 this.test.done(6); 32 test.done();
33 });
34 }); 34 });
......