This step clicks any link or interactive element that matches the given visible text exactly. The locator targets a, button, input[type="button"], input[type="submit"], and elements with role="button", selecting the first one whose full visible text matches case-sensitively. It is the general-purpose click step and is suitable for navigation links, action buttons, and labelled controls alike.
The text match is exact and case-sensitive: "Read more" will not match an element reading "Read More". If multiple elements share the same label, the first one in DOM order is clicked. When the target element is not immediately visible, use a "wait for" step beforehand. If the element has no visible text, use the attribute variant on page 260 instead. On failure the step emits a descriptive error that includes the text it searched for and troubleshooting hints.
Accepted phrasings
When I click "Contact Us"
When we click "Read more"
And I click "Home"
And click "About"
Examples
When I click "Contact Us"
And I click "aboutUs"
When we click "Read more"
And click "Home"
In a real scenario
Scenario: Navigate from the homepage to the about page
Given I am on "/"
When I click "About"
And wait
Then I should see "Our story"
And the url should match "/about"
Related steps
- Click link or button by attribute - click using an id, class, or data attribute instead of text
- Press button by visible text - similar step focused on button and submit elements
- Click action in table row - click a link or button within a specific table row
- Attach file to input - set a file on a file input element