Count
Methods
Table of Contents
count
Parameters
selector
string CSS selector of the element or elements to checkuserOptions
(optional, default{}
)options
Object Additional options
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