Asserts that the rendered HTML response of the current page contains a given piece of text. The step reads the text content of the entire <html> element, so it can find text that is not visually rendered on the page: content inside <head> (meta descriptions, JSON-LD blocks), <noscript> fallbacks, or hidden regions of the markup.
The single parameter is the text to look for, and matching is a plain case-sensitive substring check against the page source text. Use this step when the normal visible-text assertion Then I should see "..." is too strict; the negated counterpart is Then the response should not contain "...".
Accepted phrasings
Then the response should contain "text"
Then response should contain "text"
Examples
Then the response should contain "Welcome visitor"
And the response should contain "<title>Home</title>"
Then the response should contain "<html"
Then response should contain "Our mission"
In a real scenario
Feature: Site pages expose the expected markup
Scenario: Check the About page source
When I go to "https://example.org/about"
And wait 2s
Then I should see "About us"
And the response should contain "<title>About us</title>"
And the response should contain "Our mission"
And the response should not contain "Access denied"