diff --git a/test/functional/apidemos/findElement.js b/test/functional/apidemos/findElement.js index ae6b6dd9c..f404ba2d1 100644 --- a/test/functional/apidemos/findElement.js +++ b/test/functional/apidemos/findElement.js @@ -172,6 +172,16 @@ describeWd('xpath', function(h) { }); }); }); + it('should find the last element', function(done) { + h.driver.elementByXPath("//text[last()]", function(err, el) { + should.not.exist(err); + el.text(function(err, text) { + should.not.exist(err); + text.should.eql("Accessibility"); + done(); + }); + }); + }); it('should find element by xpath index and child', function(done) { h.driver.elementByXPath("//frame[1]/frame[1]/list[1]/text[3]", function(err, el) { should.not.exist(err); diff --git a/test/functional/uicatalog/findElement.js b/test/functional/uicatalog/findElement.js index 707ba4f12..978c524c7 100644 --- a/test/functional/uicatalog/findElement.js +++ b/test/functional/uicatalog/findElement.js @@ -74,6 +74,18 @@ var setupXpath = function(d, cb) { }; describeWd('findElement(s)ByXpath', function(h) { + it('should return the last button', function(done) { + setupXpath(h.driver, function() { + h.driver.elementByXPath("//button[last()]", function(err, el) { + should.not.exist(err); + el.text(function(err, text) { + should.not.exist(err); + text.should.equal("Back"); + done(); + }); + }); + }); + }); it('should return a single element', function(done) { setupXpath(h.driver, function() { h.driver.elementByXPath("//button", function(err, el) {