UNPKG

cypress-cucumber-steps

Version:
94 lines (88 loc) 2.13 kB
import { DataTable, When } from '@badeball/cypress-cucumber-preprocessor'; import { PseudoSelector } from '../constants'; import { getButtonElements, setCypressElement } from '../utils'; /** * When I find buttons by text: * * ```gherkin * When I find buttons by text {string} * ``` * * @example * * ```gherkin * When I find buttons by text "Button" * ``` * * With [options](https://docs.cypress.io/api/commands/get#Arguments): * * ```gherkin * When I find buttons by text "Button" * | log | true | * | timeout | 4000 | * | withinSubject | null | * | includeShadowDom | false | * ``` * * @remarks * * This precedes steps like {@link When_I_click | "When I click"}. For example: * * ```gherkin * When I find buttons by text "Button" * And I get 1st element * And I click * ``` * * @see * * - {@link When_I_find_button_by_text | When I find button by text} */ export function When_I_find_buttons_by_text(text: string, options?: DataTable) { setCypressElement(getButtonElements(text, PseudoSelector.visible, options)); } When('I find buttons by text {string}', When_I_find_buttons_by_text); /** * When I find button by text: * * ```gherkin * When I find button by text {string} * ``` * * Finds first button element that matches text. * * @example * * ```gherkin * When I find button by text "Button" * ``` * * With [options](https://docs.cypress.io/api/commands/get#Arguments): * * ```gherkin * When I find button by text "Button" * | log | true | * | timeout | 4000 | * | withinSubject | null | * | includeShadowDom | false | * ``` * * @remarks * * This precedes steps like {@link When_I_click | "When I click"}. For example: * * ```gherkin * When I find button by text "Button" * And I click * ``` * * @see * * - {@link When_I_find_buttons_by_text | When I find buttons by text} */ export function When_I_find_button_by_text(text: string, options?: DataTable) { setCypressElement( getButtonElements(text, PseudoSelector.visible, options).first(), ); } When('I find button by text {string}', When_I_find_button_by_text);