Demo
GUIDE

Text-entry components

3 MIN READ

Single-line text field

Use for names, subjects, identifiers, addresses, and other plain text.

gherkin
When I fill "Automation Account {timestamp}" in the "Account Name" text field
Then the "Account Name" field should contain "Automation Account {timestamp}"

Use replace when the field already contains a value:

gherkin
When I replace the value in the "Subject" text field with "Updated request {timestamp}"
Then the "Subject" field should contain exactly "Updated request {timestamp}"

Use clear when blank is the intended state:

gherkin
When I clear the "Middle Name" text field
Then the "Middle Name" field should be empty

Do not write fill the name without naming the exact field and value.

Email, phone, URL, and password fields

Name the visible field and keep the value externalised:

gherkin
When I fill [$.testdata.contact.email] in the "Email" field
And I fill [$.testdata.contact.phone] in the "Phone" field
And I fill [$.testdata.contact.website] in the "Website" field

For passwords, confirm the outcome rather than attempting to read the masked value:

gherkin
When I fill [$.testdata.login.password] in the "Password" field
And I click the "Sign In" button
Then the "Dashboard" heading should be visible

Multiline textarea

Use textarea or multiline field, and state whether line breaks matter:

gherkin
When I fill the "Internal Notes" textarea with the following text:
  """
  Customer requested expedited handling.
  Manager approval is attached.
  """
Then the "Internal Notes" textarea should contain both lines in the same order

Rich-text editor

Treat content and formatting as separate responsibilities.

For content only:

gherkin
When I fill the "Case Description" rich-text editor with:
  """
  Customer cannot access the portal.
  Reset attempted twice.
  """
Then the "Case Description" rich-text editor should contain both sentences

For formatting:

gherkin
When I select the text "Critical customer" in the "Case Description" rich-text editor
And I click the "Bold" toolbar button for that editor
Then "Critical customer" should be bold in the "Case Description" editor

For links:

gherkin
When I select the text "Support policy" in the "Resolution" rich-text editor
And I use the "Insert Link" toolbar action with URL [$.testdata.case.policy_url]
Then "Support policy" should link to [$.testdata.case.policy_url]

Always scope toolbar buttons to their editor when more than one editor is present.

Numeric, currency, percentage, and spinbutton fields

State the semantic type and the expected normalisation:

gherkin
When I fill `12500.50` in the "Annual Revenue" currency field
Then the "Annual Revenue" field should show the value `12,500.50`

When I set the "Discount" percentage field to `15`
Then the "Discount" field should show `15%`

Do not include currency symbols in the input unless the control requires them. Confirm the displayed value using the application's locale.

Use search for the query action. Keep searching separate from choosing a result:

gherkin
When I search for [$.testdata.account.name] using the "Search Accounts" field
And I wait until the search results finish loading
Then a result named [$.testdata.account.name] should be visible

Autocomplete or typeahead

Searching is not selection. Always select a result and confirm the committed value:

gherkin
When I search for "San" using the "City" autocomplete field
And I select "San Francisco" from the suggestions
Then the "City" field should show "San Francisco"