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

Commit 31d42a3

Browse files
committed
fix(protractor): throw index-out-of-bounds
See #915 - to make error more specific instead of propagate later
1 parent 46ef24b commit 31d42a3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/protractor.js

+6
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)