Then I should see "value" in the "text" element

This step asserts that a specific element contains a given piece of text. It takes two quoted arguments: the expected text and the element to inspect. The element can be identified either by a CSS selector or by its visible label text: when the label matches a form label with a for attribute, the step follows it to the associated form control, so "Username" resolves to the input the label points at.

The step waits up to 5 seconds for the element to appear, then reads its text content and passes when the expected text appears anywhere inside it (a substring match, not an exact match). Because the assertion is scoped to one element, it is more precise than the page-wide "I should see" step and will not pass just because the text happens to appear elsewhere on the page.

Accepted phrasings

Then I should see "<text>" in the "<element>" element
Then we should see "<text>" in the "<element>" element
Then should see "<text>" in "<element>" element
And I should see "<text>" in the "<element>" element

Examples

Then I should see "John Smith" in the "Username" element
Then I should see "Published" in the "#status" element
And we should see "3 items" in the ".cart-summary" element
And I should see "Welcome back" in the "#greeting" element

In a real scenario

Feature: Account dashboard

  Scenario: Dashboard greets the signed-in user by name
    Given I am a logged in user with the "customer" user
     When I go to "/dashboard"
      And wait
     Then I should see "Dashboard"
      And I should see "John Smith" in the "Username" element
      And I should see "Active" in the "#account-status" element
      And I should not see "Joe Smith" in the "Username" element

Related steps

Back to Assertion Steps