From a2afb4d8399ba980674c79138dd98efb683e9ab9 Mon Sep 17 00:00:00 2001 From: Julie Date: Mon, 2 Dec 2013 06:31:54 -0800 Subject: [PATCH] fix(element): element.all.get and element.all.first/last should wrap web elements Closes #307 --- lib/protractor.js | 6 +++--- spec/basic/findelements_spec.js | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/protractor.js b/lib/protractor.js index df4dc46e1..cb4959743 100644 --- a/lib/protractor.js +++ b/lib/protractor.js @@ -106,7 +106,7 @@ var buildElementHelper = function(ptor) { var id = ptor.findElements(locator).then(function(arr) { return arr[index]; }); - return new webdriver.WebElement(ptor.driver, id); + return ptor.wrapWebElement(new webdriver.WebElement(ptor.driver, id)); }; elementArrayFinder.first = function() { @@ -116,14 +116,14 @@ var buildElementHelper = function(ptor) { } return arr[0]; }); - return new webdriver.WebElement(ptor.driver, id); + return ptor.wrapWebElement(new webdriver.WebElement(ptor.driver, id)); }; elementArrayFinder.last = function() { var id = ptor.findElements(locator).then(function(arr) { return arr[arr.length - 1]; }); - return new webdriver.WebElement(ptor.driver, id); + return ptor.wrapWebElement(new webdriver.WebElement(ptor.driver, id)); }; elementArrayFinder.then = function(fn) { diff --git a/spec/basic/findelements_spec.js b/spec/basic/findelements_spec.js index 11d2ef4c9..55bc9f21a 100644 --- a/spec/basic/findelements_spec.js +++ b/spec/basic/findelements_spec.js @@ -464,6 +464,15 @@ describe('wrapping web driver elements', function() { element.all(by.binding('planet.name')).then(function(results) { results.forEach(verifyMethodsAdded); }); + element.all(by.binding('planet.name')).get(0).then(function(elem) { + elem.verifyMethodsAdded; + }); + element.all(by.binding('planet.name')).first().then(function(elem) { + elem.verifyMethodsAdded; + }); + element.all(by.binding('planet.name')).last().then(function(elem) { + elem.verifyMethodsAdded; + }); element.all(by.css('option[value="4"]')).then(function(results) { results.forEach(verifyMethodsAdded); });