tikiwiki/packages/tiki-pkg-casperjs/jerome-breton/casperjs/tests/suites/casper/elementattribute.js
2023-11-20 20:52:04 +00:00

21 lines
1.0 KiB
JavaScript
Executable File

/*eslint strict:0*/
var x = require('casper').selectXPath;
casper.test.begin('getElementAttribute() tests', 4, function(test) {
casper.start('tests/site/elementattribute.html', function() {
test.assertEquals(this.getElementAttribute('.testo', 'data-stuff'),
'beautiful string', 'Casper.getElementAttribute() works with a CSS selector');
test.assertEquals(this.getElementAttribute(x('//div[@class]'), 'data-stuff'),
'beautiful string', 'Casper.getElementAttribute() works with a XPath selector');
}).then(function() {
test.assertEquals(this.getElementsAttribute('.testo', 'data-stuff'),
['beautiful string', 'not as beautiful string'],
'Casper.getElementsAttribute() works with a CSS selector');
test.assertEquals(this.getElementsAttribute(x('//div[@class]'), 'data-stuff'),
['beautiful string', 'not as beautiful string'],
'Casper.getElementsAttribute() works with a XPath selector');
}).run(function() {
test.done();
});
});