Methods

Table of Contents

count

Parameters

  • selector string CSS selector of the element or elements to check
  • userOptions (optional, default {})
  • options Object Additional options
    • options.scope string Add scope
    • options.resetScope boolean Ignore parent scope
    • options.testContainer string Context where to search elements in the DOM

Examples

// <span>1</span>
// <span>2</span>

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

const page = create({
  spanCount: count('span')
});

assert.equal(page.spanCount, 2);
// <div>Text</div>

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

const page = create({
  spanCount: count('span')
});

assert.equal(page.spanCount, 0);
// <div><span></span></div>
// <div class="scope"><span></span><span></span></div>

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

const page = create({
  spanCount: count('span', { scope: '.scope' })
});

assert.equal(page.spanCount, 2)
// <div><span></span></div>
// <div class="scope"><span></span><span></span></div>

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

const page = create({
  scope: '.scope',
  spanCount: count('span')
});

assert.equal(page.spanCount, 2)
// <div><span></span></div>
// <div class="scope"><span></span><span></span></div>

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

const page = create({
  scope: '.scope',
  spanCount: count('span', { resetScope: true })
});

assert.equal(page.spanCount, 1);

Returns Descriptor