Is present
Methods
Table of Contents
isPresent
Validates if any element matching the target selector is rendered in the DOM.
isPresent vs. isVisible:
- Both validate that an element matching the target selector can be found in the DOM
isVisibleadditionally validates that all matching elements are visible
Some uses cases for isPresent over isVisible:
- To check for the presence of a tag that is never visible in the DOM (e.g.
<meta>). - To validate that, even though an element may not currently be visible, it is still in the DOM.
- To validate that an element has not merely been hidden but has in fact been removed from the DOM.
Parameters
selectorstring CSS selector of the element to checkuserOptions(optional, default{})optionsObject Additional options
Examples
// Lorem <span>ipsum</span>
import { create, isPresent } from 'ember-cli-page-object';
const page = create({
spanIsPresent: isPresent('span')
});
assert.ok(page.spanIsPresent);
// <head>
// <meta name='robots' content='noindex'>
// </head>
import { create, isPresent } from 'ember-cli-page-object';
const page = create({
notIndexed: isPresent(`meta[name='robots'][content='noindex']`, {
testContainer: 'head'
})
});
assert.ok(page.notIndexed);
// Lorem <strong>ipsum</strong>
import { create, isPresent } from 'ember-cli-page-object';
const page = create({
spanIsPresent: isPresent('span')
});
// returns false when element doesn't exist in DOM
assert.notOk(page.spanIsPresent);
- Throws any Will throw an error if multiple elements are matched by selector
Returns Descriptor