Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
fix(element): element.all.get and element.all.first/last should wrap …
Browse files Browse the repository at this point in the history
…web elements

Closes #307
  • Loading branch information
juliemr committed Dec 2, 2013
1 parent a69ebc3 commit a2afb4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions spec/basic/findelements_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit a2afb4d

Please sign in to comment.