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

Commit bf123ad

Browse files
authored
feat(elements): Add isPresent() to ElementArrayFinder. (#3974)
1 parent b9cc224 commit bf123ad

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/element.ts

+16
Original file line numberDiff line numberDiff 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
*

spec/basic/elements_spec.js

+7
Original file line numberDiff line numberDiff 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');

0 commit comments

Comments
 (0)