Then I should be

Asserts where the browser currently is. This family of steps covers four assertions: the current page is the homepage, is not the homepage, is a specific page, or is not a specific page. The homepage forms compare the current URL against the launch URL configured for the test run; the quoted-path forms check whether the current URL contains the given path or full URL.

All variants accept I or we (or no pronoun at all), an optional the, and homepage or frontpage interchangeably. The quoted form also accepts a trailing page keyword. Because the specific-page check is a substring match on the URL, prefer distinctive paths: asserting "/" will match almost any URL, and asserting not on a short fragment can fail unexpectedly if the fragment appears elsewhere in the URL.

Accepted phrasings

Then I should be on homepage
Then I should be on the homepage
Then we should be on the frontpage
Then should be on homepage
Then I should not be on the homepage

Then I should be on "/path"
Then we should be on the "/path" page
Then should be on the "/path" page
Then I should not be on "/path"
Then we should not be on the "https://example.org" page

Examples

Then I should be on the homepage
And we should not be on homepage
Then I should be on "/user/login"
And I should not be on "/admin"

In a real scenario

Scenario: The password reset form redirects the visitor to the homepage
  Given I am on the homepage
   When I go to "/user/password"
    And I wait 3s
   Then I should see "Username or email address"
   When I fill in "someone@example.org" for "Username or email address"
    And I press the "Reset" button
    And I wait 3s
   Then I should be on the homepage
    And I should not be on "/user/password"

Related steps

Back to Navigation Steps