Click on-text
Methods
Table of Contents
clickOnText
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 textuserOptions
(optional, default{}
)options
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
Examples
// <fieldset>
// <button>Lorem</button>
// <button>Ipsum</button>
// </fieldset>
import { create, clickOnText } from 'ember-cli-page-object';
const page = create({
clickOnFieldset: clickOnText('fieldset'),
clickOnButton: 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>
import { create, clickOnText } from 'ember-cli-page-object';
const page = create({
clickOnFieldset: clickOnText('fieldset', { scope: '.scope' }),
clickOnButton: 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>
import { create, clickOnText } from 'ember-cli-page-object';
const page = create({
scope: '.scope',
clickOnFieldset: clickOnText('fieldset'),
clickOnButton: 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