Skip to content

Commit

Permalink
feat(queries): add "When I get elements by selector"
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Sep 27, 2023
1 parent 4d85b08 commit 925deee
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/queries/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,38 @@ import { setCypressElement } from '../utils';
*
* @see
*
* - {@link When_I_get_elements_by_selector | When I get elements by selector}
* - {@link When_I_find_element_by_selector | When I find element by selector}
*/
export function When_I_get_element_by_selector(selector: string) {
setCypressElement(cy.get(selector).first());
}

When('I get element by selector {string}', When_I_get_element_by_selector);

/**
* When I get elements by selector:
*
* ```gherkin
* When I get elements by selector {string}
* ```
*
* Get DOM elements by selector.
*
* @example
*
* Yield all `<li>` in `.list`:
*
* ```gherkin
* When I get elements by selector ".list > li"
* ```
*
* @see
*
* - {@link When_I_get_element_by_selector | When I get element by selector}
*/
export function When_I_get_elements_by_selector(selector: string) {
setCypressElement(cy.get(selector));
}

When('I get elements by selector {string}', When_I_get_elements_by_selector);

0 comments on commit 925deee

Please sign in to comment.