This step asserts that a form field contains specific text. The field is located by its visible label text, or directly by a CSS selector if the value starts with # or .. When a label is given, the step resolves the for attribute on the matching label element and targets the associated input by ID. The step waits up to 5 seconds for the element to be present before reading its value or text content.
This is the right step for confirming that a form was pre-populated correctly, that a save-and-reload preserved a field value, or that a default was applied. For the negative form, use the "should not contain" variant. For asserting text visible in a non-form element on the page, use the I should see family of steps instead.
Accepted phrasings
Then the "FieldLabel" field should contain "value"
Then the "#css-selector" field should contain "value"
Then the ".css-class" field should contain "value"
Examples
Then the "Username" field should contain "John Smith"
And the "Email" field should contain "jon@example.org"
Then the "#edit-title-0-value" field should contain "My Page Title"
Then the ".search-input" field should contain "webship"
In a real scenario
Scenario: Confirm that the edit form is pre-filled with the saved article title
Given I am a logged in user with the "editor" user
When I go to "/content"
And wait
And I open the "Edit" link in the "Quarterly Report" row
And wait
Then the "Title" field should contain "Quarterly Report"
And the "Email" field should contain "editor@example.org"