@wordpress/e2e-test-utils
Version:
End-To-End (E2E) test utils for WordPress.
21 lines (19 loc) • 927 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findSidebarPanelWithTitle = findSidebarPanelWithTitle;
/** @typedef {import('puppeteer-core').ElementHandle} ElementHandle */
/**
* Finds the button responsible for toggling the sidebar panel with the provided title.
*
* @param {string} panelTitle The name of sidebar panel.
*
* @return {Promise<ElementHandle|undefined>} Object that represents an in-page DOM element.
*/
async function findSidebarPanelWithTitle(panelTitle) {
const panelToggleSelector = `//div[contains(@class, "editor-sidebar")]//button[contains(@class, "components-panel__body-toggle") and contains(text(),"${panelTitle}")]`;
const panelSelector = `${panelToggleSelector}/ancestor::*[contains(concat(" ", @class, " "), " components-panel__body ")]`;
return await page.waitForXPath(panelSelector);
}
//# sourceMappingURL=find-sidebar-panel-with-title.js.map