Skip to content

Commit

Permalink
feat(elements): Add isPresent() to ElementArrayFinder. (angular#3974)
Browse files Browse the repository at this point in the history
  • Loading branch information
heathkit authored and igniteram committed Feb 21, 2017
1 parent 27a4bc8 commit 7bf8ac4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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

0 comments on commit 7bf8ac4

Please sign in to comment.