Contains
Methods
Table of Contents
contains
Returns a boolean representing whether an element or a set of elements contains the specified text.
Parameters
selectorstring CSS selector of the element to checkuserOptions(optional, default{})optionsObject Additional optionsoptions.scopestring Nests provided scope within parent’s scopeoptions.atnumber Reduce the set of matched elements to the one at the specified indexoptions.resetScopeboolean Override parent’s scopeoptions.multipleboolean Check if all elements matched by selector contain the subtextoptions.testContainerstring Context where to search elements in the DOM
Examples
// Lorem <span>ipsum</span>
import { create, contains } from 'ember-cli-page-object';
const page = create({
spanContains: contains('span')
});
assert.ok(page.spanContains('ipsum'));
// <span>lorem</span>
// <span>ipsum</span>
// <span>dolor</span>
const page = PageObject.create({
spansContain: PageObject.contains('span', { multiple: true })
});
// not all spans contain 'lorem'
assert.notOk(page.spansContain('lorem'));
// <span>super text</span>
// <span>regular text</span>
import { create, contains } from 'ember-cli-page-object';
const page = create({
spansContain: contains('span', { multiple: true })
});
// all spans contain 'text'
assert.ok(page.spansContain('text'));
// <div><span>lorem</span></div>
// <div class="scope"><span>ipsum</span></div>
// <div><span>dolor</span></div>
import { create, contains } from 'ember-cli-page-object';
const page = create({
spanContains: contains('span', { scope: '.scope' })
});
assert.notOk(page.spanContains('lorem'));
assert.ok(page.spanContains('ipsum'));
// <div><span>lorem</span></div>
// <div class="scope"><span>ipsum</span></div>
// <div><span>dolor</span></div>
import { create, contains } from 'ember-cli-page-object';
const page = create({
scope: '.scope',
spanContains: contains('span')
});
assert.notOk(page.spanContains('lorem'));
assert.ok(page.spanContains('ipsum'));
- Throws any Will throw an error if no element matches selector
- Throws any Will throw an error if multiple elements are matched by selector and multiple option is not set
Returns Descriptor