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({ 8 type: 'xpath',
9 type: 'xpath', 9 path: '/html/body/ul/li[2]'
10 path: '/html/body/ul/li[2]' 10 }, 'XPath selector can find an element');
11 }, 'XPath selector can find an element'); 11 test.assertDoesntExist({
12 this.test.assertDoesntExist({ 12 type: 'xpath',
13 type: 'xpath', 13 path: '/html/body/ol/li[2]'
14 path: '/html/body/ol/li[2]' 14 }, 'XPath selector does not retrieve an unexistent element');
15 }, 'XPath selector does not retrieve an unexistent element'); 15 test.assertExists(x('/html/body/ul/li[2]'), 'selectXPath() shortcut can find an element as well');
16 this.test.assertExists(x('/html/body/ul/li[2]'), 'selectXPath() shortcut can find an element as well'); 16 test.assertEvalEquals(function() {
17 this.test.assertEvalEquals(function() { 17 return __utils__.findAll({type: 'xpath', path: '/html/body/ul/li'}).length;
18 return __utils__.findAll({type: 'xpath', path: '/html/body/ul/li'}).length; 18 }, 3, 'Correct number of elements are found');
19 }, 3, 'Correct number of elements are found'); 19 });
20 });
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'
25 });
26 test.assertEvalEquals(function() {
27 return document.querySelector('input[name="email"]').value;
28 }, 'chuck@norris.com', 'Casper.fill() can fill an input[type=text] form field');
26 }); 29 });
27 this.test.assertEvalEquals(function() {
28 return document.querySelector('input[name="email"]').value;
29 }, 'chuck@norris.com', 'Casper.fill() can fill an input[type=text] form field');
30 });
31 30
32 casper.run(function() { 31 casper.run(function() {
33 this.test.done(6); 32 test.done();
33 });
34 }); 34 });
......