Skip to content

Commit

Permalink
feat(elements): Add isPresent() to ElementArrayFinder. (#3974)
Browse files Browse the repository at this point in the history
  • Loading branch information
heathkit committed Jan 18, 2017
1 parent b9cc224 commit bf123ad
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
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

This comment has been minimized.

Copy link
@bvasilchik

bvasilchik Feb 7, 2017

is this supposed to be either one these?

expect($$('.item').isPresent()).toBeTruthy();
expect(element.all(by.css('.item')).isPresent()).toBeTruthy();

* 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
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 bf123ad

Please sign in to comment.