When I fill in "field" with empty value by its attribute

Enters an empty value into a field that is located by an HTML attribute, effectively clearing it. The step ends with with: (no value) followed by the by attr suffix, which switches lookup from label matching to attribute matching. It is most often used when a text field needs to be empty: wiping a pre-populated value before saving, or preparing a required-field validation test.

The field can be specified by id, class, name, or placeholder. The # sign for id and the . sign for class are optional: "#username" and "username" both work when the input's id is username. A bare token is matched against common attributes (id, class, name, data-testid, aria-label, placeholder, title, and more); add by its "..." attribute to restrict the match to one specific attribute.

Accepted phrasings

When I fill in "#username" with: by attribute
When we fill in ".username" with: by attr
When I fill in "username" with: by attr
When I fill in "username" with: by its "name" attr
When I fill in "username" with: by its "placeholder" attribute

Examples

When I fill in "#username" with: by attribute
When we fill in ".username" with: by attr
When I fill in "username" with: by its "name" attr
When I fill in "username" with: by its "placeholder" attribute

In a real scenario

Scenario: Verify an error is shown when the description is cleared on a required field
  Given I am logged in as a content editor
   When I go to "/blog/add"
    And wait
    And I fill in "Test Blog Post" for "Title"
    And I fill in "#edit-field-description-0-value" with: by attribute
    And I press the "Save" button
    And wait
   Then I should see "Description field is required"

Related steps

Back to Form Steps