This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 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 {
428428 } ) ;
429429 }
430430
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+
431447 /**
432448 * Returns the most relevant locator.
433449 *
Original file line number Diff line number Diff line change @@ -357,6 +357,13 @@ describe('ElementArrayFinder', function() {
357357 expect ( element . all ( by . binding ( 'doesnotexist' ) ) . count ( ) ) . toEqual ( 0 ) ;
358358 } ) ;
359359
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+
360367 it ( 'should return not present when an element disappears within an array' ,
361368 function ( ) {
362369 browser . get ( 'index.html#/form' ) ;
You can’t perform that action at this time.
0 commit comments