When I move focus to "fieldLabel" field

The When I move focus to "[field]" field step programmatically moves keyboard focus to a form field identified by its accessible label, placeholder text, ARIA role, name attribute, or id. It uses an accessibility-first lookup chain: Playwright's getByLabel is tried first, then getByPlaceholder, then getByRole('textbox', { name: field }), and finally a CSS attribute selector combining [name="..."] and #id. The first element that matches any of these strategies is focused with locator.focus().

The field name is a quoted string, not a registered selector name. This distinguishes it from the layout selector steps that use the named registry. Use this step to simulate tab-order navigation in accessibility tests, to position focus before a keyboard shortcut step, or to verify that a field that has lost focus can be re-activated. Follow it with Then I see [subject] has focus to assert the result, using a registered selector name for the same element.

Accepted phrasings

When I move focus to "[field]" field
When we move focus to "[field]" field
When move focus to "[field]" field

Examples

When I move focus to "Title" field
When I move focus to "Email" field
When I move focus to "Search" field
When we move focus to "Password" field

In a real scenario

Scenario: Editing a pre-filled title field replaces the existing text
  Given I define css selectors:
    | title field | input[name="title"] |
  When I go to "https://example.org/content/edit/42"
  And I move focus to "Title" field
  And I select all text in "Title" field
  And I type "Updated article title"
  Then I see title field has focus

Related steps

Back to Selectors Steps