Keypress

Command value: keypress

Presses a single key on an element.

Fields

FieldJSON propertyDescription
TargettargetRequired. CSS selector or XPath of the element that receives the key press.
KeyvalueOne of: F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, Alt, Ctrl, Shift, Tab, Enter, Escape, Backspace, Delete, Home, End, PageUp, PageDown, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Cancel, Clear, Help, Pause, Print, Insert.
Description (Optional)notesA comment shown in the step list and in Gherkin and Playwright exports.

Usage

  • Press Enter to submit a search field, Escape to close a dialog, or Tab to move focus.
  • Key names are not case-sensitive. ArrowDown, Backspace, Esc and Del are also accepted. An unrecognised key fails the step.

Example step (JSON)

{
  "command": "keypress",
  "target": "#search",
  "value": "Enter"
}

Playwright equivalent

await page.locator('#search').press('Enter');

Common options

  • Make this step optional (Continue on failure): when checked, a failure in this step is recorded and the test continues with the next step.
  • Execute step when JavaScript returns true: runs the step only when the JavaScript condition returns true. Otherwise the step is skipped.

See conditional steps and variables for details.