Skip to content

Commit

Permalink
feat(queries): pass options to "I get first element"
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Nov 30, 2023
1 parent 6c4be41 commit 22293b5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/queries/first.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { When } from '@badeball/cypress-cucumber-preprocessor';
import { DataTable, When } from '@badeball/cypress-cucumber-preprocessor';

import { getCypressElement, setCypressElement } from '../utils';
import { getCypressElement, getOptions, setCypressElement } from '../utils';

/**
* When I get first element:
Expand All @@ -15,6 +15,14 @@ import { getCypressElement, setCypressElement } from '../utils';
* When I get first element
* ```
*
* With [options](https://docs.cypress.io/api/commands/first#Arguments):
*
* ```gherkin
* When I get first element
* | log | true |
* | timeout | 4000 |
* ```
*
* @remarks
*
* This follows steps like {@link When_I_find_links_by_text | "When I find links by text"} and precedes steps like {@link When_I_click | "When I click"}. For example:
Expand All @@ -30,8 +38,8 @@ import { getCypressElement, setCypressElement } from '../utils';
* - {@link When_I_get_nth_element | When I get nth element}
* - {@link When_I_get_last_element | When I get last element}
*/
export function When_I_get_first_element() {
setCypressElement(getCypressElement().first());
export function When_I_get_first_element(options?: DataTable) {
setCypressElement(getCypressElement().first(getOptions(options)));
}

When('I get first element', When_I_get_first_element);

0 comments on commit 22293b5

Please sign in to comment.