Click on-text
Methods
clickOnText
addon/-private/properties/click-on-text.js:81-101
Clicks on an element containing specified text.
The element can either match a specified selector, or be inside an element matching the specified selector.
Parameters
selector
string CSS selector of the element in which to look for textoptions
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.visible
boolean Make the action to raise an error if the element is not visibleoptions.resetScope
boolean Override parent’s scopeoptions.testContainer
string Context where to search elements in the DOM
userOptions
(optional, default{}
)
Examples
// <fieldset>
// <button>Lorem</button>
// <button>Ipsum</button>
// </fieldset>
const page = PageObject.create({
clickOnFieldset: PageObject.clickOnText('fieldset'),
clickOnButton: PageObject.clickOnText('button')
});
// queries the DOM with selector 'fieldset :contains("Lorem"):last'
page.clickOnFieldset('Lorem');
// queries the DOM with selector 'button:contains("Ipsum")'
page.clickOnButton('Ipsum');
// <div class="scope">
// <fieldset>
// <button>Lorem</button>
// <button>Ipsum</button>
// </fieldset>
// </div>
const page = PageObject.create({
clickOnFieldset: PageObject.clickOnText('fieldset', { scope: '.scope' }),
clickOnButton: PageObject.clickOnText('button', { scope: '.scope' })
});
// queries the DOM with selector '.scope fieldset :contains("Lorem"):last'
page.clickOnFieldset('Lorem');
// queries the DOM with selector '.scope button:contains("Ipsum")'
page.clickOnButton('Ipsum');
// <div class="scope">
// <fieldset>
// <button>Lorem</button>
// <button>Ipsum</button>
// </fieldset>
// </div>
const page = PageObject.create({
scope: '.scope',
clickOnFieldset: PageObject.clickOnText('fieldset'),
clickOnButton: PageObject.clickOnText('button')
});
// queries the DOM with selector '.scope fieldset :contains("Lorem"):last'
page.clickOnFieldset('Lorem');
// queries the DOM with selector '.scope button:contains("Ipsum")'
page.clickOnButton('Ipsum');
Returns Descriptor