fixes #438 - getElementAttribute to works with XPath
Showing
2 changed files
with
8 additions
and
4 deletions
... | @@ -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 | }); | ... | ... |
-
Please register or sign in to post a comment