This step asserts that the full visible text of the page matches a given regular expression pattern. It reads document.body.innerText and constructs a JavaScript RegExp from the pattern string you supply. The check runs once without retrying, so place it after a wait step when the content may still be loading.
The pattern is treated as a case-sensitive JavaScript regular expression. You can use any valid JS regex syntax: anchors, character classes, quantifiers, and alternation. Both I and we are accepted as the subject. Use this step when a plain string match is too rigid - for example, to verify a year appears anywhere on the page, or that a price format is present without knowing the exact amount. For the negative counterpart, see Then I should not see text matching.
Accepted phrasings
Then I should see text matching "pattern"
Then we should see text matching "pattern"
And I should see text matching "pattern"
And we should see text matching "pattern"
Examples
Then I should see text matching "^Tw+"
And we should see text matching "d{4}"
Then I should see text matching "Order #d+"
And I should see text matching "(Active|Enabled)"
In a real scenario
Scenario: Check that an anonymous user does not see admin toolbar items on the homepage
Given I am an anonymous user
When I go to the homepage
And wait
Then I should see "Welcome"
And I should not see text matching "Tasks"
And I should not see text matching "Delete"
And I should not see text matching "Manage display"