When I fill in "field" with:

Clears an input field, leaving it empty. The step ends with with: and no value, which is the Gherkin way of saying "fill this field with nothing". The field is located by its visible label, its placeholder text, or its name attribute - whichever matches first.

Use this step to empty a pre-populated field before typing a new value, or to test validation of required fields by submitting a form with a blank input. Note the trailing colon is part of the step text: without it the step would not match. If you need to target the field by id, class, or another attribute instead of its label, use the by attr variant of this step.

Accepted phrasings

When I fill in "field" with:
When we fill in "field" with:
And I fill in "field" with:

Examples

When I fill in "Username" with:
And we fill in "Email" with:
And I fill in "Password" with:

In a real scenario

Scenario: Verify a form error after clearing the username and password on login
  Given I am on "/user/login"
    And wait
   When I fill in "Username or email address" with:
    And I fill in "Password" with:
    And I scroll to bottom
    And I press "Log in"
    And wait
   Then I should see "error"

Related steps

Back to Form Steps