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

Clears an input field that is located by an HTML attribute rather than its label, leaving the field empty. The step ends with with: and no value, followed by the by attr suffix that switches lookup from label matching to attribute matching. It is typically used to blank out a pre-filled field before entering new text, or to test required-field validation.

The quoted argument may be a shorthand selector - #username for an id, .username for a class - or a bare token. A bare token is matched against common attributes (id, class, name, data-testid, aria-label, placeholder, title, and more). To pin the lookup to a single attribute, use the by its "name" attribute form. The # and . prefixes are optional when matching by id or class.

Accepted phrasings

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

Examples

When I fill in "#uname" with: by attr
When I fill in "uname" with: by attr
And I fill in "pwordcss" with: by "class" attr
And I fill in "Your full name" with: by its "placeholder" attribute

In a real scenario

Scenario: Verify the description field can be blanked before saving a page
  Given I am logged in on the site
   When I go to "/pages/add"
    And wait
    And I fill in "Test Unpublished Page" for "Title"
    And I fill in "#edit-field-description-0-value" with: by attr
    And I press the "Save" button
    And wait
   Then I should see "Test Unpublished Page"

Related steps

Back to Form Steps