2020-09-20 23:54:08 +00:00
|
|
|
/** @typedef {import('react')} React */
|
|
|
|
|
2020-07-29 13:39:15 +00:00
|
|
|
/**
|
|
|
|
* Finds the label of a toggle control.
|
|
|
|
*
|
|
|
|
* @param {string} label The label associated with a toggle control.
|
|
|
|
*
|
2020-09-20 23:54:08 +00:00
|
|
|
* @return {?React.ReactElementHandle} Object that represents an in-page DOM element.
|
2020-07-29 13:39:15 +00:00
|
|
|
*/
|
2020-09-14 07:46:58 +00:00
|
|
|
export async function findLabelWithText( label ) {
|
2020-07-29 13:39:15 +00:00
|
|
|
const [ toggle ] = await page.$x(
|
2020-09-14 07:46:58 +00:00
|
|
|
`//div[contains(@class,"components-base-control")]//label[contains(text(), '${ label }')]`
|
2020-07-29 13:39:15 +00:00
|
|
|
);
|
|
|
|
return toggle;
|
|
|
|
}
|