UNPKG

cypress-cucumber-steps

Version:
30 lines 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getButtonElements = getButtonElements; var options_1 = require("./options"); /** * Get button elements. * * @param text - Button text. * @param selector - Pseudo selector. * @returns - Cypress element. * @private */ function getButtonElements(text, selector, options) { var selectors = [ 'button', "[type='button']", "[type='submit']", "[role='button']", ]; selectors = selectors.reduce(function (accumulator, button) { accumulator.push("".concat(button, ":contains(").concat(JSON.stringify(text), ")")); accumulator.push("".concat(button, "[value=").concat(JSON.stringify(text), "]")); return accumulator; }, []); if (selector) { selectors = selectors.map(function (button) { return "".concat(button, ":").concat(selector); }); } return cy.get(selectors.join(','), (0, options_1.getOptions)(options)); } //# sourceMappingURL=button.js.map