Asserts that the browser is currently on a specific page. The quoted argument can be a relative path such as "/user/login" or a full URL such as "https://example.org". The step passes when the current browser URL contains the quoted value, so it works for both exact paths and meaningful URL fragments. The pronoun can be I, we, or omitted, the is optional, and a trailing page keyword is also optional.
Gotcha: because this is a substring check, very short values match too easily. Asserting "/" passes on virtually every URL, and asserting "/user" also passes on /user/login. Prefer the most specific path that identifies the page you expect. When the assertion fails, the error message shows the actual current URL.
Accepted phrasings
Then I should be on "/path"
Then I should be on the "/path" page
Then we should be on "/path"
Then we should be on the "/path" page
Then should be on "/path"
Then should be on the "/path" page
Examples
Then I should be on "/user/login"
And we should be on "/user/reset"
Then should be on the "/contact-us.html" page
And I should be on "https://example.org"
In a real scenario
Scenario: Anonymous visitors are sent to the login page instead of the admin area
Given I am an anonymous user
When I go to "/admin"
And wait
Then I should see "Log in"
And I should be on "/user/login"
And I should not be on "/admin/dashboard"