Text
Methods
text
addon/-private/properties/text.js:92-112
Parameters
selectorstring CSS selector of the element to checkoptionsObject 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 Return an array of valuesoptions.normalizeboolean Set tofalseto avoid text normalizationoptions.testContainerString Context where to search elements in the DOM
Examples
// Hello <span>world!</span>
const page = PageObject.create({
text: PageObject.text('span')
});
assert.equal(page.text, 'world!');
// <span>lorem</span>
// <span> ipsum </span>
// <span>dolor</span>
const page = PageObject.create({
texts: PageObject.text('span', { multiple: true })
});
assert.deepEqual(page.texts, ['lorem', 'ipsum', 'dolor']);
// <div><span>lorem</span></div>
// <div class="scope"><span>ipsum</span></div>
// <div><span>dolor</span></div>
const page = PageObject.create({
text: PageObject.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>
const page = PageObject.create({
scope: '.scope',
text: PageObject.text('span')
});
// returns 'ipsum'
assert.equal(page.text, 'ipsum');
// <div><span>lorem</span></div>
// <div class="scope">
// ipsum
// </div>
// <div><span>dolor</span></div>
const page = PageObject.create({
scope: '.scope',
text: PageObject.text('span', { normalize: false })
});
// returns 'ipsum'
assert.equal(page.text, '\n ipsum\n');
Returns Descriptor