@@ -237,6 +237,35 @@ function testUntilElementLocated() {
237
237
} ) ;
238
238
}
239
239
240
+ function runNoElementFoundTest ( locator , locatorStr ) {
241
+ executor . on ( CommandName . FIND_ELEMENTS , function ( cmd , callback ) {
242
+ callback ( null , bot . response . createResponse ( [ ] ) ) ;
243
+ } ) ;
244
+
245
+ function expectedFailure ( ) {
246
+ fail ( 'expected condition to timeout' ) ;
247
+ }
248
+
249
+ return driver . wait ( until . elementLocated ( locator ) , 100 )
250
+ . then ( expectedFailure , function ( error ) {
251
+ var expected = 'Waiting for element to be located ' + locatorStr ;
252
+ var lines = error . message . split ( / \n / , 2 ) ;
253
+ assertEquals ( expected , lines [ 0 ] ) ;
254
+ assertRegExp ( / ^ W a i t t i m e d o u t a f t e r \d + m s $ / , lines [ 1 ] ) ;
255
+ } ) ;
256
+ }
257
+
258
+ function testUntilElementLocated_elementNeverFound_byLocator ( ) {
259
+ return runNoElementFoundTest ( By . id ( 'quux' ) , 'By.id("quux")' ) ;
260
+ }
261
+
262
+ function testUntilElementLocated_elementNeverFound_byHash ( ) {
263
+ return runNoElementFoundTest ( { id : 'quux' } , 'By.id("quux")' ) ;
264
+ }
265
+
266
+ function testUntilElementLocated_elementNeverFound_byFunction ( ) {
267
+ return runNoElementFoundTest ( goog . nullFunction , 'by function()' ) ;
268
+ }
240
269
241
270
function testUntilElementsLocated ( ) {
242
271
var responses = [ [ ] , [ { ELEMENT : 'abc123' } , { ELEMENT : 'foo' } ] , [ 'end' ] ] ;
@@ -257,6 +286,36 @@ function testUntilElementsLocated() {
257
286
} ) ;
258
287
}
259
288
289
+ function runNoElementsFoundTest ( locator , locatorStr ) {
290
+ executor . on ( CommandName . FIND_ELEMENTS , function ( cmd , callback ) {
291
+ callback ( null , bot . response . createResponse ( [ ] ) ) ;
292
+ } ) ;
293
+
294
+ function expectedFailure ( ) {
295
+ fail ( 'expected condition to timeout' ) ;
296
+ }
297
+
298
+ return driver . wait ( until . elementsLocated ( locator ) , 100 )
299
+ . then ( expectedFailure , function ( error ) {
300
+ var expected =
301
+ 'Waiting for at least one element to be located ' + locatorStr ;
302
+ var lines = error . message . split ( / \n / , 2 ) ;
303
+ assertEquals ( expected , lines [ 0 ] ) ;
304
+ assertRegExp ( / ^ W a i t t i m e d o u t a f t e r \d + m s $ / , lines [ 1 ] ) ;
305
+ } ) ;
306
+ }
307
+
308
+ function testUntilElementsLocated_noElementsEverFound_byLocator ( ) {
309
+ return runNoElementsFoundTest ( By . id ( 'quux' ) , 'By.id("quux")' ) ;
310
+ }
311
+
312
+ function testUntilElementsLocated_noElementsEverFound_byHash ( ) {
313
+ return runNoElementsFoundTest ( { id : 'quux' } , 'By.id("quux")' ) ;
314
+ }
315
+
316
+ function testUntilElementsLocated_noElementsEverFound_byFunction ( ) {
317
+ return runNoElementsFoundTest ( goog . nullFunction , 'by function()' ) ;
318
+ }
260
319
261
320
function testUntilStalenessOf ( ) {
262
321
var responses = [
0 commit comments