testdriver/press-keys.yaml
version: 6.0.0
steps:
  - prompt: create a new tab and inspect elements
    commands:
      - command: focus-application
        name: Google Chrome
      - command: hover-text
        text: Sign In
        description: black button below the password field
        action: click
      - command: press-keys
        keys:
          - ctrl
          - t
      - command: wait-for-text
        text: "Learn more"
      - command: press-keys
        keys:
          - ctrl
          - shift
          - i
      - command: wait-for-text
        text: "Elements"
      - command: press-keys
        keys:
          - ctrl
          - t
      - command: type
        text: google.com
      - command: press-keys
        keys:
          - enter
      - command: assert
        expect: google appears

Description

The press-keys command is used to simulate typing a keyboard combination. This is useful for triggering shortcuts or interacting with applications via keyboard input.

Arguments

ArgumentTypeDescription
keysYAML sequence of stringsA list of keys to press together.

The keys supported are the standard Windows keys. Supported values:
  • ctrl, shift, alt, command, option, win
  • Left/right variants: ctrlleft, ctrlright, shiftleft, shiftright, altleft, altright, optionleft, optionright, winleft, winright

Example usage

command: press-keys
keys:
  - ctrl
  - space

Protips

  • Use this command to trigger system-wide or application-specific shortcuts, such as the Start menu or the browser elements.
  • Ensure the application or system is in focus when using this command to avoid unexpected behavior.

Notes

  • The press-keys command is ideal for automating workflows that rely on keyboard shortcuts.