Count
Methods
count
addon/-private/properties/count.js:74-89
Parameters
selector
string CSS selector of the element or elements to checkoptions
Object Additional optionsoptions.scope
string Add scopeoptions.resetScope
boolean Ignore parent scopeoptions.testContainer
String Context where to search elements in the DOM
Examples
// <span>1</span>
// <span>2</span>
const page = PageObject.create({
spanCount: PageObject.count('span')
});
assert.equal(page.spanCount, 2);
// <div>Text</div>
const page = PageObject.create({
spanCount: PageObject.count('span')
});
assert.equal(page.spanCount, 0);
// <div><span></span></div>
// <div class="scope"><span></span><span></span></div>
const page = PageObject.create({
spanCount: PageObject.count('span', { scope: '.scope' })
});
assert.equal(page.spanCount, 2)
// <div><span></span></div>
// <div class="scope"><span></span><span></span></div>
const page = PageObject.create({
scope: '.scope',
spanCount: PageObject.count('span')
});
assert.equal(page.spanCount, 2)
// <div><span></span></div>
// <div class="scope"><span></span><span></span></div>
const page = PageObject.create({
scope: '.scope',
spanCount: PageObject.count('span', { resetScope: true })
});
assert.equal(page.spanCount, 1);
Returns Descriptor