Skip to content

Commit

Permalink
fix(protractor): throw index-out-of-bounds
Browse files Browse the repository at this point in the history
See angular#915
- to make error more specific instead of propagate later
  • Loading branch information
hankduan committed Jun 16, 2014
1 parent 24248d6 commit e8bba50
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,12 @@ var buildElementHelper = function(ptor) {
// -1 is special and means last
index = arr.length - 1;
}

if (index >= arr.length) {
throw new Error('Index out of bound. Trying to access index:' + index +
', but locator: ' + locatorMessage + ' only has ' +
arr.length + ' elements');
}
return arr[index];
});
return new webdriver.WebElement(ptor.driver, id);
Expand Down

0 comments on commit e8bba50

Please sign in to comment.