Skip to content

Commit

Permalink
fix(actions): fix options in click steps
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Dec 8, 2023
1 parent 417ae1f commit aa60988
Showing 1 changed file with 18 additions and 46 deletions.
64 changes: 18 additions & 46 deletions src/actions/click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,30 +212,23 @@ When('I click {int}px and {int}px', When_I_click_x_y_coordinates);
* When I click on button "Button"
* ```
*
* With [options](https://docs.cypress.io/api/commands/click#Arguments):
* With [options](https://docs.cypress.io/api/commands/get#Arguments):
*
* ```gherkin
* When I click on button "Button"
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | log | true |
* | force | false |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* | withinSubject | null |
* | includeShadowDom | false |
* ```
*
* @see
*
* - {@link When_I_click_on_text | When I click on text}
*/
export function When_I_click_on_button(text: string, options?: DataTable) {
When_I_find_button_by_text(text);
getCypressElement().click(getOptions(options));
When_I_find_button_by_text(text, options);
getCypressElement().click();
}

When('I click on button {string}', When_I_click_on_button);
Expand All @@ -255,29 +248,22 @@ When('I click on button {string}', When_I_click_on_button);
* When I click on link "Link"
* ```
*
* With [options](https://docs.cypress.io/api/commands/click#Arguments):
* With [options](https://docs.cypress.io/api/commands/contains#Arguments):
*
* ```gherkin
* When I click on link "Link"
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | matchCase | true |
* | log | true |
* | force | false |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* | includeShadowDom | false |
* ```
*
* @see
*
* - {@link When_I_click_on_text | When I click on text}
*/
export function When_I_click_on_link(text: string, options?: DataTable) {
cy.contains('a', text).first().click(getOptions(options));
cy.contains('a', text, getOptions(options)).first().click();
}

When('I click on link {string}', When_I_click_on_link);
Expand All @@ -299,21 +285,14 @@ When('I click on link {string}', When_I_click_on_link);
* When I click on text "Text"
* ```
*
* With [options](https://docs.cypress.io/api/commands/click#Arguments):
* With [options](https://docs.cypress.io/api/commands/contains#Arguments):
*
* ```gherkin
* When I click on text "Text"
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | matchCase | true |
* | log | true |
* | force | false |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* | includeShadowDom | false |
* ```
*
* @see
Expand All @@ -323,7 +302,7 @@ When('I click on link {string}', When_I_click_on_link);
* - {@link When_I_click_on_link | When I click on link}
*/
export function When_I_click_on_text(text: string, options?: DataTable) {
cy.contains(text).click(getOptions(options));
cy.contains(text, getOptions(options)).click();
}

When('I click on text {string}', When_I_click_on_text);
Expand All @@ -341,30 +320,23 @@ When('I click on text {string}', When_I_click_on_text);
* When I click on label "Label"
* ```
*
* With [options](https://docs.cypress.io/api/commands/click#Arguments):
* With [options](https://docs.cypress.io/api/commands/get#Arguments):
*
* ```gherkin
* When I click on label "Label"
* | altKey | false |
* | animationDistanceThreshold | 5 |
* | ctrlKey | false |
* | log | true |
* | force | false |
* | metaKey | false |
* | multiple | false |
* | scrollBehavior | top |
* | shiftKey | false |
* | timeout | 4000 |
* | waitForAnimations | true |
* | withinSubject | null |
* | includeShadowDom | false |
* ```
*
* @see
*
* - {@link When_I_click_on_text | When I click on text}
*/
export function When_I_click_on_label(text: string, options?: DataTable) {
When_I_find_element_by_label_text(text);
getCypressElement().click(getOptions(options));
When_I_find_element_by_label_text(text, options);
getCypressElement().click();
}

When('I click on label {string}', When_I_click_on_label);

0 comments on commit aa60988

Please sign in to comment.