This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -243,10 +243,10 @@ ElementArrayFinder.prototype.get = function(index) {
243
243
i = parentWebElements . length + i ;
244
244
}
245
245
if ( i < 0 || i >= parentWebElements . length ) {
246
- throw new Error ( 'Index out of bound. Trying to access element at ' +
247
- 'index: ' + index + ', but there are only ' +
248
- parentWebElements . length + ' elements that match locator ' +
249
- self . locator_ . toString ( ) ) ;
246
+ throw new webdriver . error . NoSuchElementError ( 'Index out of bound. ' +
247
+ 'Trying to access element at index: ' + index + ', but there are ' +
248
+ 'only ' + parentWebElements . length + ' elements that match ' +
249
+ 'locator ' + self . locator_ . toString ( ) ) ;
250
250
}
251
251
return [ parentWebElements [ i ] ] ;
252
252
} ) ;
Original file line number Diff line number Diff line change @@ -111,6 +111,13 @@ describe('ElementFinder', function() {
111
111
} ) ;
112
112
} ) ;
113
113
114
+ it ( 'isPresent() should be friendly with out of bounds error' , function ( ) {
115
+ browser . get ( 'index.html#/form' ) ;
116
+ var elementsNotPresent = element . all ( by . id ( 'notPresentElementID' ) ) ;
117
+ expect ( elementsNotPresent . first ( ) . isPresent ( ) ) . toBe ( false ) ;
118
+ expect ( elementsNotPresent . last ( ) . isPresent ( ) ) . toBe ( false ) ;
119
+ } ) ;
120
+
114
121
it ( 'isPresent() should not raise error on chained finders' , function ( ) {
115
122
browser . get ( 'index.html#/form' ) ;
116
123
var elmFinder = $ ( '.nopenopenope' ) . element ( by . binding ( 'greet' ) ) ;
You can’t perform that action at this time.
0 commit comments