UNPKG

@wordpress/e2e-test-utils

Version:
31 lines (29 loc) 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clickBlockToolbarButton = clickBlockToolbarButton; var _showBlockToolbar = require("./show-block-toolbar"); /** * Internal dependencies */ /** * Clicks a block toolbar button. * * @param {string} label The text string of the button label. * @param {string} [type] The type of button label: 'ariaLabel' or 'content'. */ async function clickBlockToolbarButton(label, type = 'ariaLabel') { await (0, _showBlockToolbar.showBlockToolbar)(); const BLOCK_TOOLBAR_SELECTOR = 'block-editor-block-toolbar'; let button; if (type === 'ariaLabel') { button = await page.waitForSelector(`.${BLOCK_TOOLBAR_SELECTOR} button[aria-label="${label}"]`); } if (type === 'content') { button = await page.waitForXPath(`//*[contains(concat(' ', normalize-space(@class), ' '), ' ${BLOCK_TOOLBAR_SELECTOR} ')]//button[contains(text(), '${label}')]`); } await button.evaluate(element => element.scrollIntoView()); await button.click(); } //# sourceMappingURL=click-block-toolbar-button.js.map