Commit 2bcc009f 2bcc009ff54e0a8a525df98b07873b22d7b8dbd3 by Nicolas Perriault

migrated xpath tests

1 parent c61f0f18
......@@ -2,33 +2,33 @@
/*jshint strict:false*/
var x = require('casper').selectXPath;
casper.test.comment('XPath');
casper.start('tests/site/index.html', function() {
this.test.assertExists({
type: 'xpath',
path: '/html/body/ul/li[2]'
}, 'XPath selector can find an element');
this.test.assertDoesntExist({
type: 'xpath',
path: '/html/body/ol/li[2]'
}, 'XPath selector does not retrieve an unexistent element');
this.test.assertExists(x('/html/body/ul/li[2]'), 'selectXPath() shortcut can find an element as well');
this.test.assertEvalEquals(function() {
return __utils__.findAll({type: 'xpath', path: '/html/body/ul/li'}).length;
}, 3, 'Correct number of elements are found');
});
casper.test.begin('XPath tests', 6, function(test) {
casper.start('tests/site/index.html', function() {
test.assertExists({
type: 'xpath',
path: '/html/body/ul/li[2]'
}, 'XPath selector can find an element');
test.assertDoesntExist({
type: 'xpath',
path: '/html/body/ol/li[2]'
}, 'XPath selector does not retrieve an unexistent element');
test.assertExists(x('/html/body/ul/li[2]'), 'selectXPath() shortcut can find an element as well');
test.assertEvalEquals(function() {
return __utils__.findAll({type: 'xpath', path: '/html/body/ul/li'}).length;
}, 3, 'Correct number of elements are found');
});
casper.thenClick(x('/html/body/a[2]'), function() {
this.test.assertTitle('CasperJS test form', 'Clicking XPath works as expected');
this.fill(x('/html/body/form'), {
email: 'chuck@norris.com'
casper.thenClick(x('/html/body/a[2]'), function() {
test.assertTitle('CasperJS test form', 'Clicking XPath works as expected');
this.fill(x('/html/body/form'), {
email: 'chuck@norris.com'
});
test.assertEvalEquals(function() {
return document.querySelector('input[name="email"]').value;
}, 'chuck@norris.com', 'Casper.fill() can fill an input[type=text] form field');
});
this.test.assertEvalEquals(function() {
return document.querySelector('input[name="email"]').value;
}, 'chuck@norris.com', 'Casper.fill() can fill an input[type=text] form field');
});
casper.run(function() {
this.test.done(6);
casper.run(function() {
test.done();
});
});
......