When I press "button"

This step clicks a button, submit input, or link element identified by its exact visible text. It searches for button, input[type="button"], input[type="submit"], elements with role="button", and a elements, filtering to the first one whose visible text matches the given label exactly (case-sensitive). The optional words the and button in the phrasing are accepted but have no effect on the selector.

The match is case-sensitive and must be exact - a label of Log In will not match a button reading Log in. If the button is not yet visible when the step runs, use a "wait for" step first. If the button has no readable text label (for example it contains only an icon), use the attribute variant on page 258 instead. On failure, the step reports the element text it could not find along with troubleshooting hints.

Accepted phrasings

When I press "Log In"
When we press "Submit"
When I press the "Save" button
And I press the "Save as" button
And press "Cancel"

Examples

When I press "Log In"
And I press the "Log In" button
And I press the "Save as" button
When we press "Submit"
And press "Cancel"

In a real scenario

Scenario: User logs in with valid credentials
  Given I am on "/user/login"
  When I fill in "alice" for "Username or email address"
    And I fill in "s3cr3t!" for "Password"
    And I scroll to bottom
    And I press "Log in"
  Then I should see "alice"

Related steps

Back to Action Steps