This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -428,6 +428,22 @@ export class ElementArrayFinder extends WebdriverWebElement {
428
428
} ) ;
429
429
}
430
430
431
+ /**
432
+ * Returns true if there are any elements present that match the finder.
433
+ *
434
+ * @alias element.all(locator).isPresent()
435
+ *
436
+ * @example
437
+ * expect($('.item').isPresent()).toBeTruthy();
438
+ *
439
+ * @returns {Promise<boolean> }
440
+ */
441
+ isPresent ( ) : wdpromise . Promise < boolean > {
442
+ return this . count ( ) . then ( ( count ) => {
443
+ return count > 0 ;
444
+ } ) ;
445
+ }
446
+
431
447
/**
432
448
* Returns the most relevant locator.
433
449
*
Original file line number Diff line number Diff line change @@ -357,6 +357,13 @@ describe('ElementArrayFinder', function() {
357
357
expect ( element . all ( by . binding ( 'doesnotexist' ) ) . count ( ) ) . toEqual ( 0 ) ;
358
358
} ) ;
359
359
360
+ it ( 'supports isPresent()' , function ( ) {
361
+ browser . get ( 'index.html#/form' ) ;
362
+
363
+ expect ( element . all ( by . model ( 'color' ) ) . isPresent ( ) ) . toBeTruthy ( ) ;
364
+ expect ( element . all ( by . binding ( 'doesnotexist' ) ) . isPresent ( ) ) . toBeFalsy ( ) ;
365
+ } ) ;
366
+
360
367
it ( 'should return not present when an element disappears within an array' ,
361
368
function ( ) {
362
369
browser . get ( 'index.html#/form' ) ;
You can’t perform that action at this time.
0 commit comments