Then I should not see text matching "text pattern" in the "element" element

This step asserts that the text content of a specific element does not match a regular expression pattern. It takes two quoted arguments: the pattern to test and a CSS selector for the target element. The step locates the first element that matches the selector, waits up to 5 seconds for it to appear, reads its text content, and fails the scenario if the pattern matches that text.

Use the negative form to prove that unwanted content (error markers, placeholder values, unformatted data) is absent from a scoped part of the page rather than the whole document. Note that the element itself must still exist: if the selector matches nothing, the step times out and fails. To assert an element is missing entirely, use the element-absence step instead.

Accepted phrasings

Then I should not see text matching "<pattern>" in the "<selector>" element
Then we should not see text matching "<pattern>" in the "<selector>" element
Then should not see text matching "<pattern>" in "<selector>" element
And I should not see text matching "<pattern>" in the "<selector>" element

Examples

Then I should not see text matching "Error" in the "#status" element
Then I should not see text matching "d{4}" in the "#username" element
And we should not see text matching "^Pending" in the "#order-state" element
Then I should not see text matching "TODO" in the ".release-notes" element

In a real scenario

Feature: Order confirmation

  Scenario: Confirmation page shows a clean status
    Given I am a logged in user with the "customer" user
     When I go to "/orders/12345"
      And wait
     Then I should see "Order #12345"
      And I should see text matching "$d+.d{2}" in the "#order-total" element
      And I should not see text matching "Error" in the "#status" element
      And I should not see text matching "Pending" in the "#status" element

Related steps

Back to Assertion Steps