When I fill in

This is the overview page for the fill-in family of form steps. These steps let you type text into input fields, textareas, and other fillable elements on the page. The family covers label-based lookup, attribute-based lookup, reverse (value-first) syntax, multi-field data tables, and clearing fields by filling with an empty value.

All variants delegate to the same internal fillField helper, which first clears the field then types the new value. If you pass an empty string the field is cleared. Both I and we pronouns are accepted, and the steps may be introduced with Given, When, or And.

Accepted phrasings

When I fill in "Username" with "John Smith"
When we fill in "Email" with "jon@example.org"
When I fill in "Password" with "s3cret"

When I fill in "#uname" with "John Smith" by attr
When I fill in "uname" with "John Smith" by attr
And I fill in "Your full name" with "John Smith" by its "placeholder" attribute

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

When I fill in "#uname" with: by attr
When I fill in "username" with: by its "name" attribute

When I fill in "jon-smith" for "Username"
When we fill in "1234" for "Password"

When I fill in "John Smith" for "#uname" by attr
And I fill in "John Smith" for "Your full name" by its "placeholder" attribute

When I fill in the following:
  | Username | alice       |
  | Password | s3cret      |

When I fill in the following: by attr
  | #uname   | alice       |
  | password | s3cret      |

Examples

When I fill in "Username" with "John Smith"
When I fill in "#uname" with "John Smith" by attr
When I fill in "jon-smith" for "Username"
When I fill in the following:
  | Email    | user@example.org |
  | Password | s3cret           |

In a real scenario

Scenario: Visitor submits a contact form
  Given I am an anonymous user
    And I go to "/contact-us"
    And wait
   When I fill in "First Name" with "Alice"
    And I fill in "Last name" with "Smith"
    And I fill in "Company name" with "Example Corp"
    And I fill in "Subject" with "Automated test inquiry"
   Then the field "First Name" should not be empty
    And the field "Subject" should not be empty

Related steps

Back to Form Steps