Methods

Table of Contents

text

Parameters

  • selector string CSS selector of the element to check
  • userOptions (optional, default {})
  • options Object Additional options
    • options.scope string Nests provided scope within parent’s scope
    • options.at number Reduce the set of matched elements to the one at the specified index
    • options.resetScope boolean Override parent’s scope
    • options.multiple boolean Return an array of values
    • options.normalize boolean Set to false to avoid text normalization
    • options.testContainer string 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!');
// <span>lorem</span>
// <span> ipsum </span>
// <span>dolor</span>

import { create, text } from 'ember-cli-page-object';

const page = create({
  texts: 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>

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 and multiple option is not set

Returns Descriptor