Then I save screenshot with name "filename"

Saves a screenshot of the current viewport using an explicit filename instead of the automatically generated one. Both a PNG and a matching .html snapshot are written to the screenshot directory (default ./screenshots), so a name like homepage produces homepage.png and homepage.html. If the name does not end with an extension placeholder, the correct extension is appended automatically.

The filename supports tokens that are replaced at capture time, which keeps names unique and descriptive: {datetime} (timestamp, with optional format such as {datetime:YYYY-MM-DD}), {feature_file} (feature file name), {step_line} (line number of the step), {step_name} (step text), and URL tokens like {url_path}, {url_domain}, and {url_origin}. Without a {datetime} token, repeated runs overwrite the same file, which is often exactly what you want for stable review artifacts.

Accepted phrasings

Then I save screenshot with name "homepage.png"
Then we save screenshot with name "homepage.png"
Then save screenshot with name "homepage.png"
When I save screenshot with name "homepage.png"
And I save screenshot with name "homepage.png"

Examples

Then I save screenshot with name "homepage.png"
Then I save screenshot with name "landing-{datetime}.png"
Then I save screenshot with name "{feature_file}_{step_line}"
Then I save screenshot with name "{url_path}.png"

In a real scenario

Scenario: Capture the login form before and after an empty submit
  Given I am on "/user/login"
   Then I save screenshot with name "login-form-initial.png"
   When I press "Log in"
   Then I should see "Username field is required."
    And I save screenshot with name "login-form-errors.png"

Related steps

Back to Screenshot Steps