Skip to content

Commit

Permalink
feat(actions): pass options to "When I click"
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Nov 11, 2023
1 parent 19d713b commit 01889e6
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/actions/click.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { When } from '@badeball/cypress-cucumber-preprocessor';
import { DataTable, When } from '@badeball/cypress-cucumber-preprocessor';

import {
When_I_find_button_by_text,
When_I_find_element_by_label_text,
} from '../queries';
import { getCypressElement } from '../utils';
import { getCypressElement, getOptions } from '../utils';

/**
* When I click:
Expand All @@ -23,6 +23,23 @@ import { getCypressElement } from '../utils';
* When I click
* ```
*
* With [options](https://docs.cypress.io/api/commands/click#Arguments):
*
* ```gherkin
* When I click
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | log | true |
* | force | false |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* ```
*
* @remarks
*
* A preceding step like {@link When_I_find_element_by_text | "When I find element by text"} is required. For example:
Expand All @@ -37,8 +54,8 @@ import { getCypressElement } from '../utils';
* - {@link When_I_double_click | When I double-click}
* - {@link When_I_right_click | When I right-click}
*/
export function When_I_click() {
getCypressElement().click();
export function When_I_click(options?: DataTable) {
getCypressElement().click(getOptions(options));
}

When('I click', When_I_click);
Expand Down

0 comments on commit 01889e6

Please sign in to comment.