Skip to content

Commit e8bba50

Browse files
committed
fix(protractor): throw index-out-of-bounds
See angular#915 - to make error more specific instead of propagate later
1 parent 24248d6 commit e8bba50

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/protractor.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,12 @@ var buildElementHelper = function(ptor) {
584584
// -1 is special and means last
585585
index = arr.length - 1;
586586
}
587+
588+
if (index >= arr.length) {
589+
throw new Error('Index out of bound. Trying to access index:' + index +
590+
', but locator: ' + locatorMessage + ' only has ' +
591+
arr.length + ' elements');
592+
}
587593
return arr[index];
588594
});
589595
return new webdriver.WebElement(ptor.driver, id);

0 commit comments

Comments
 (0)