Has class
Methods
hasClass
addon/-private/properties/has-class.js:85-102
Validates if an element or a set of elements have a given CSS class.
Parameters
cssClass
string CSS class to be validatedselector
string CSS selector of the element to checkoptions
Object Additional optionsoptions.scope
string Nests provided scope within parent’s scopeoptions.at
number Reduce the set of matched elements to the one at the specified indexoptions.resetScope
boolean Override parent’s scopeoptions.multiple
boolean Check if all elements matched by selector have the CSS classoptions.testContainer
string Context where to search elements in the DOM
userOptions
(optional, default{}
)
Examples
// <em class="lorem"></em><span class="success">Message!</span>
const page = PageObject.create({
messageIsSuccess: PageObject.hasClass('success', 'span')
});
assert.ok(page.messageIsSuccess);
// <span class="success"></span>
// <span class="error"></span>
const page = PageObject.create({
messagesAreSuccessful: PageObject.hasClass('success', 'span', { multiple: true })
});
assert.notOk(page.messagesAreSuccessful);
// <span class="success"></span>
// <span class="success"></span>
const page = PageObject.create({
messagesAreSuccessful: PageObject.hasClass('success', 'span', { multiple: true })
});
assert.ok(page.messagesAreSuccessful);
// <div>
// <span class="lorem"></span>
// </div>
// <div class="scope">
// <span class="ipsum"></span>
// </div>
const page = PageObject.create({
spanHasClass: PageObject.hasClass('ipsum', 'span', { scope: '.scope' })
});
assert.ok(page.spanHasClass);
// <div>
// <span class="lorem"></span>
// </div>
// <div class="scope">
// <span class="ipsum"></span>
// </div>
const page = PageObject.create({
scope: '.scope',
spanHasClass: PageObject.hasClass('ipsum', 'span')
});
assert.ok(page.spanHasClass);
Returns Descriptor