Triggerable
Methods
triggerable
addon/-private/properties/triggerable.js:85-107
Triggers event on element matched by selector.
Parameters
event
string Event to be triggeredselector
string CSS selector of the element on which the event will be triggeredoptions
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 Ignore parent scopeoptions.testContainer
string Context where to search elements in the DOMoptions.eventProperties
string Event properties that will be passed to trigger function
userOptions
(optional, default{}
)
Examples
// <input class="name">
// <input class="email">
const page = PageObject.create({
focus: triggerable('focus', '.name')
});
// focuses on element with selector '.name'
page.focus();
// <input class="name">
// <input class="email">
const page = PageObject.create({
enter: triggerable('keypress', '.name', { eventProperties: { keyCode: 13 } })
});
// triggers keypress using enter key on element with selector '.name'
page.enter();
// <input class="name">
// <input class="email">
const page = PageObject.create({
keydown: triggerable('keypress', '.name')
});
// triggers keypress using enter key on element with selector '.name'
page.keydown({ which: 13 });
// <div class="scope">
// <input class="name">
// </div>
// <input class="email">
const page = PageObject.create({
focus: triggerable('focus', '.name', { scope: '.scope' })
});
// focuses on element with selector '.scope .name'
page.focus();
// <div class="scope">
// <input class="name">
// </div>
// <input class="email">
const page = PageObject.create({
scope: '.scope',
focus: triggerable('focus', '.name')
});
// focuses on element with selector '.scope .name'
page.focus();
Returns Descriptor