Commit 3787e0af 3787e0afc40993cf0b2360970f4ce61c896063b5 by Nicolas Perriault

fixes #438 - getElementAttribute to works with XPath

1 parent 9019a73a
...@@ -892,7 +892,7 @@ Casper.prototype.getElementAttr = function getElementAttr(selector, attribute) { ...@@ -892,7 +892,7 @@ Casper.prototype.getElementAttr = function getElementAttr(selector, attribute) {
892 "use strict"; 892 "use strict";
893 this.checkStarted(); 893 this.checkStarted();
894 return this.evaluate(function _evaluate(selector, attribute) { 894 return this.evaluate(function _evaluate(selector, attribute) {
895 return document.querySelector(selector).getAttribute(attribute); 895 return __utils__.findOne(selector).getAttribute(attribute);
896 }, selector, attribute); 896 }, selector, attribute);
897 }; 897 };
898 898
......
1 /*global casper*/ 1 /*global casper*/
2 /*jshint strict:false*/ 2 /*jshint strict:false*/
3 casper.test.begin('getElementAttribute() tests', 1, function(test) { 3 var x = require('casper').selectXPath;
4
5 casper.test.begin('getElementAttribute() tests', 2, function(test) {
4 casper.start('tests/site/elementattribute.html', function() { 6 casper.start('tests/site/elementattribute.html', function() {
5 test.assertEquals(this.getElementAttribute('.testo','data-stuff'), 'beautiful string', 7 test.assertEquals(this.getElementAttribute('.testo', 'data-stuff'),
6 'Casper.getElementAttribute() works as intended'); 8 'beautiful string', 'Casper.getElementAttribute() works with a CSS selector');
9 test.assertEquals(this.getElementAttribute(x('//div[@class]'), 'data-stuff'),
10 'beautiful string', 'Casper.getElementAttribute() works with a XPath selector');
7 }).run(function() { 11 }).run(function() {
8 test.done(); 12 test.done();
9 }); 13 });
......