Skip to content

Commit

Permalink
feat(queries): add "When I find elements by name"
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Oct 1, 2023
1 parent ce66cd4 commit ae8ffb1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from './input';
export * from './label';
export * from './link';
export * from './links';
export * from './names';
export * from './placeholder';
export * from './placeholders';
export * from './testid';
Expand Down
36 changes: 36 additions & 0 deletions src/queries/names.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { When } from '@badeball/cypress-cucumber-preprocessor';

import { setCypressElement } from '../utils';

/* eslint-disable tsdoc/syntax */
/**
* When I find elements by name:
*
* ```gherkin
* When I find elements by name {string}
* ```
*
* > A name is not a good substitute for a label so you should generally use {@link When_I_find_element_by_label_text | "When I find element by label text"} instead.
*
* @example
*
* ```gherkin
* When I find elements by name "text"
* ```
*
* @remarks
*
* This precedes steps like {@link When_I_type | "When I type"}. For example:
*
* ```gherkin
* When I find elements by name "password"
* And I get 1st element
* And I type "password"
* ```
*/
/* eslint-enable tsdoc/syntax */
export function When_I_find_elements_by_name(name: string) {
setCypressElement(cy.get(`[name='${name}']:visible`));
}

When('I find elements by name {string}', When_I_find_elements_by_name);

0 comments on commit ae8ffb1

Please sign in to comment.