Skip to content

Commit

Permalink
feat(actions): add "When I click on button" & "When I click on link"
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Dec 18, 2022
1 parent ec692cb commit 1567765
Showing 1 changed file with 54 additions and 6 deletions.
60 changes: 54 additions & 6 deletions src/actions/click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getCypressElement } from '../utils';
* This requires a preceding step like {@link When_I_find_element_by_text | "When I find element by text"}. For example:
*
* ```gherkin
* When I find element by text "Click Me Once"
* When I find element by text "Text"
* And I click
* ```
*
Expand All @@ -41,6 +41,54 @@ export function When_I_click() {

When('I click', When_I_click);

/**
* When I click on button:
*
* ```gherkin
* When I click on button {string}
* ```
*
* @example
*
* ```gherkin
* When I click on button "Button"
* ```
*
* @see
*
* - {@link When_I_click_on_link | When I click on link}
* - {@link When_I_click_on_text | When I click on text}
*/
export function When_I_click_on_button(text: string) {
cy.contains('button', text).click();
}

When('I click on button {string}', When_I_click_on_button);

/**
* When I click on link:
*
* ```gherkin
* When I click on link {string}
* ```
*
* @example
*
* ```gherkin
* When I click on link "Link"
* ```
*
* @see
*
* - {@link When_I_click_on_button | When I click on button}
* - {@link When_I_click_on_text | When I click on text}
*/
export function When_I_click_on_link(text: string) {
cy.contains('a', text).click();
}

When('I click on link {string}', When_I_click_on_link);

/**
* When I click on text:
*
Expand All @@ -55,7 +103,7 @@ When('I click', When_I_click);
* @example
*
* ```gherkin
* When I click on text "Click Me Once"
* When I click on text "Text"
* ```
*
* @see
Expand Down Expand Up @@ -93,7 +141,7 @@ When('I click on text {string}', When_I_click_on_text);
* This requires a preceding step like {@link When_I_find_element_by_text | "When I find element by text"}. For example:
*
* ```gherkin
* When I find element by text "Click Me Twice"
* When I find element by text "Text"
* And I double-click
* ```
*
Expand Down Expand Up @@ -124,7 +172,7 @@ When('I double-click', When_I_double_click);
* @example
*
* ```gherkin
* When I double-click on text "Click Me Twice"
* When I double-click on text "Text"
* ```
*
* @see
Expand Down Expand Up @@ -162,7 +210,7 @@ When('I double-click on text {string}', When_I_double_click_on_text);
* This requires a preceding step like {@link When_I_find_element_by_text | "When I find element by text"}. For example:
*
* ```gherkin
* When I find element by text "Right-Click Me"
* When I find element by text "Text"
* And I right-click
* ```
*
Expand Down Expand Up @@ -193,7 +241,7 @@ When('I right-click', When_I_right_click);
* @example
*
* ```gherkin
* When I right-click on text "Right-Click Me"
* When I right-click on text "Text"
* ```
*
* @see
Expand Down

0 comments on commit 1567765

Please sign in to comment.