UNPKG

cypress-cucumber-steps

Version:
154 lines 4.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.When_I_find_elements_by_alt_text = When_I_find_elements_by_alt_text; exports.When_I_find_element_by_alt_text = When_I_find_element_by_alt_text; exports.When_I_find_images_by_alt_text = When_I_find_images_by_alt_text; exports.When_I_find_image_by_alt_text = When_I_find_image_by_alt_text; var cypress_cucumber_preprocessor_1 = require("@badeball/cypress-cucumber-preprocessor"); var utils_1 = require("../utils"); /** * When I find elements by alt text: * * ```gherkin * When I find elements by alt text {string} * ``` * * Finds elements (e.g., `<img>`) that match the `alt` text. * * @example * * ```gherkin * When I find elements by alt text "Image Description" * ``` * * @remarks * * This precedes steps like {@link When_I_click | "When I click"}. For example: * * ```gherkin * When I find elements by alt text "Text" * And I get 1st element * And I click * ``` * * Inspired by Testing Library's [ByAltText](https://testing-library.com/docs/queries/byalttext). * * @see * * - {@link When_I_find_element_by_alt_text | When I find element by alt text} * - {@link When_I_find_images_by_alt_text | When I find images by alt text} */ function When_I_find_elements_by_alt_text(altText) { (0, utils_1.setCypressElement)(cy.get("[alt=".concat(JSON.stringify(altText), "]:visible"))); } (0, cypress_cucumber_preprocessor_1.When)('I find elements by alt text {string}', When_I_find_elements_by_alt_text); /** * When I find element by alt text: * * ```gherkin * When I find element by alt text {string} * ``` * * Finds the first element (e.g., `<img>`) that matches the `alt` text. * * @example * * ```gherkin * When I find element by alt text "Text" * ``` * * @remarks * * This precedes steps like {@link When_I_click | "When I click"}. For example: * * ```gherkin * When I find element by alt text "Text" * And I click * ``` * * Inspired by Testing Library's [ByAltText](https://testing-library.com/docs/queries/byalttext). * * @see * * - {@link When_I_find_elements_by_alt_text | When I find elements by alt text} * - {@link When_I_find_image_by_alt_text | When I find image by alt text} */ function When_I_find_element_by_alt_text(altText) { When_I_find_elements_by_alt_text(altText); (0, utils_1.setCypressElement)((0, utils_1.getCypressElement)().first()); } (0, cypress_cucumber_preprocessor_1.When)('I find element by alt text {string}', When_I_find_element_by_alt_text); /** * When I find images by alt text: * * ```gherkin * When I find images by alt text {string} * ``` * * Finds all `<img>` that match the `alt` text. * * @example * * ```gherkin * When I find images by alt text "Text" * ``` * * @remarks * * This precedes steps like {@link When_I_click | "When I click"}. For example: * * ```gherkin * When I find images by alt text "Text" * And I get 1st element * And I click * ``` * * Inspired by Testing Library's [ByAltText](https://testing-library.com/docs/queries/byalttext). * * @see * * - {@link When_I_find_elements_by_alt_text | When I find elements by alt text} * - {@link When_I_find_image_by_alt_text | When I find image by alt text} */ function When_I_find_images_by_alt_text(altText) { When_I_find_elements_by_alt_text(altText); (0, utils_1.setCypressElement)((0, utils_1.getCypressElement)().filter('img')); } (0, cypress_cucumber_preprocessor_1.When)('I find images by alt text {string}', When_I_find_images_by_alt_text); /** * When I find image by alt text: * * ```gherkin * When I find image by alt text {string} * ``` * * Finds the first `<img>` that matches the `alt` text. * * @example * * ```gherkin * When I find image by alt text "Text" * ``` * * @remarks * * This precedes steps like {@link When_I_click | "When I click"}. For example: * * ```gherkin * When I find image by alt text "Text" * And I click * ``` * * Inspired by Testing Library's [ByAltText](https://testing-library.com/docs/queries/byalttext). * * @see * * - {@link When_I_find_element_by_alt_text | When I find element by alt text} * - {@link When_I_find_images_by_alt_text | When I find images by alt text} */ function When_I_find_image_by_alt_text(altText) { When_I_find_images_by_alt_text(altText); (0, utils_1.setCypressElement)((0, utils_1.getCypressElement)().first()); } (0, cypress_cucumber_preprocessor_1.When)('I find image by alt text {string}', When_I_find_image_by_alt_text); //# sourceMappingURL=alt-text.js.map