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

feat(elements): Add isPresent() to ElementArrayFinder #3974

Merged
merged 1 commit into from
Jan 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,22 @@ export class ElementArrayFinder extends WebdriverWebElement {
});
}

/**
* Returns true if there are any elements present that match the finder.
*
* @alias element.all(locator).isPresent()
*
* @example
* expect($('.item').isPresent()).toBeTruthy();
*
* @returns {Promise<boolean>}
*/
isPresent(): wdpromise.Promise<boolean> {
return this.count().then((count) => {
return count > 0;
});
}

/**
* Returns the most relevant locator.
*
Expand Down
7 changes: 7 additions & 0 deletions spec/basic/elements_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ describe('ElementArrayFinder', function() {
expect(element.all(by.binding('doesnotexist')).count()).toEqual(0);
});

it('supports isPresent()', function() {
browser.get('index.html#/form');

expect(element.all(by.model('color')).isPresent()).toBeTruthy();
expect(element.all(by.binding('doesnotexist')).isPresent()).toBeFalsy();
});

it('should return not present when an element disappears within an array',
function() {
browser.get('index.html#/form');
Expand Down