Text
Methods
Table of Contents
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.normalizeboolean Set tofalseto avoid text normalizationoptions.testContainerstring Context where to search elements in the DOM
Examples
// Hello <span>world!</span>
import { create, text } from 'ember-cli-page-object';
const page = create({
text: text('span')
});
assert.equal(page.text, 'world!');
// <div><span>lorem</span></div>
// <div class="scope"><span>ipsum</span></div>
// <div><span>dolor</span></div>
import { create, text } from 'ember-cli-page-object';
const page = create({
text: text('span', { scope: '.scope' })
});
assert.equal(page.text, 'ipsum');
// <div><span>lorem</span></div>
// <div class="scope"><span>ipsum</span></div>
// <div><span>dolor</span></div>
import { create, text } from 'ember-cli-page-object';
const page = create({
scope: '.scope',
text: text('span')
});
// returns 'ipsum'
assert.equal(page.text, 'ipsum');
// <div><span>lorem</span></div>
// <div class="scope">
// ipsum
// </div>
// <div><span>dolor</span></div>
import { create, text } from 'ember-cli-page-object';
const page = create({
scope: '.scope',
text: text('span', { normalize: false })
});
// returns 'ipsum'
assert.equal(page.text, '\n ipsum\n');
- Throws any Will throw an error if no element matches selector
- Throws any Will throw an error if multiple elements are matched by selector
Returns Descriptor