UNPKG

cypress-cucumber-steps

Version:
110 lines 3.54 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.When_I_find_elements_by_label_text = When_I_find_elements_by_label_text; exports.When_I_find_element_by_label_text = When_I_find_element_by_label_text; var cypress_cucumber_preprocessor_1 = require("@badeball/cypress-cucumber-preprocessor"); var constants_1 = require("../constants"); var utils_1 = require("../utils"); /** * When I find elements by label text: * * ```gherkin * When I find elements by label text {string} * ``` * * Find all visible `label`, `aria-labelledby`, or `aria-label` that matches the text. * * @example * * ```gherkin * When I find elements by label text "Email" * ``` * * With [options](https://docs.cypress.io/api/commands/get#Arguments): * * ```gherkin * When I find elements by label text "Email" * | log | true | * | timeout | 4000 | * | withinSubject | null | * | includeShadowDom | false | * | pseudoSelector | visible | * ``` * * @remarks * * This precedes steps like {@link When_I_type | "When I type"}. For example: * * ```gherkin * When I find elements by label text "Email" * And I get 1st element * And I type "user@example.com" * ``` * * Inspired by Testing Library's [ByLabelText](https://testing-library.com/docs/queries/bylabeltext). * * @see * * - {@link When_I_find_element_by_label_text | When I find element by label text } */ function When_I_find_elements_by_label_text(text, options) { (0, utils_1.setCypressElement)((0, utils_1.getLabelElements)(text, __assign({ pseudoSelector: constants_1.PseudoSelector.visible }, (0, utils_1.getOptions)(options)))); } (0, cypress_cucumber_preprocessor_1.When)('I find elements by label text {string}', When_I_find_elements_by_label_text); /** * When I find element by label text: * * ```gherkin * When I find element by label text {string} * ``` * * Find the first visible `label`, `aria-labelledby`, or `aria-label` that matches the text. * * @example * * ```gherkin * When I find element by label text "Email" * ``` * * With [options](https://docs.cypress.io/api/commands/get#Arguments): * * ```gherkin * When I find element by label text "Email" * | log | true | * | timeout | 4000 | * | withinSubject | null | * | includeShadowDom | false | * | pseudoSelector | visible | * ``` * * @remarks * * This precedes steps like {@link When_I_type | "When I type"}. For example: * * ```gherkin * When I find element by label text "Email" * And I type "user@example.com" * ``` * * Inspired by Testing Library's [ByLabelText](https://testing-library.com/docs/queries/bylabeltext). * * @see * * - {@link When_I_find_elements_by_label_text | When I find elements by label text } */ function When_I_find_element_by_label_text(text, options) { (0, utils_1.setCypressElement)((0, utils_1.getLabelElements)(text, __assign({ pseudoSelector: constants_1.PseudoSelector.visible }, (0, utils_1.getOptions)(options))).first()); } (0, cypress_cucumber_preprocessor_1.When)('I find element by label text {string}', When_I_find_element_by_label_text); //# sourceMappingURL=label.js.map