Class W3cKeys

java.lang.Object
io.karatelabs.driver.w3c.W3cKeys
All Implemented Interfaces:
Keys

public class W3cKeys extends Object implements Keys
W3C WebDriver Actions API keyboard input implementation.

Uses the W3C Actions API (POST /session/{id}/actions) which properly supports modifier keys (Ctrl, Shift, Alt, Meta) and key combinations. This is the correct W3C approach — v1 also used the actions endpoint for WebDriver.

For simple typing, uses sendKeys on the active element (more efficient). For modifier combos and special keys, uses the Actions API.

  • Method Details

    • type

      public Keys type(String text)
      Description copied from interface: Keys
      Type a sequence of characters.
      Specified by:
      type in interface Keys
      Parameters:
      text - the text to type
      Returns:
      this for chaining
    • press

      public Keys press(String key)
      Description copied from interface: Keys
      Press and release a key.
      Specified by:
      press in interface Keys
      Parameters:
      key - the key to press (can be a special key constant or single character)
      Returns:
      this for chaining
    • down

      public Keys down(String key)
      Description copied from interface: Keys
      Hold down a modifier key.
      Specified by:
      down in interface Keys
      Parameters:
      key - the modifier key (SHIFT, CONTROL, ALT, META)
      Returns:
      this for chaining
    • up

      public Keys up(String key)
      Description copied from interface: Keys
      Release a modifier key.
      Specified by:
      up in interface Keys
      Parameters:
      key - the modifier key (SHIFT, CONTROL, ALT, META)
      Returns:
      this for chaining
    • combo

      public Keys combo(String[] modifierKeys, String key)
      Description copied from interface: Keys
      Press a key combination (e.g., Ctrl+A, Shift+Tab).
      Specified by:
      combo in interface Keys
      Parameters:
      modifierKeys - the modifier keys to hold
      key - the key to press
      Returns:
      this for chaining
    • ctrl

      public Keys ctrl(String key)
      Description copied from interface: Keys
      Press Ctrl+key combination.
      Specified by:
      ctrl in interface Keys
    • alt

      public Keys alt(String key)
      Description copied from interface: Keys
      Press Alt+key combination.
      Specified by:
      alt in interface Keys
    • shift

      public Keys shift(String key)
      Description copied from interface: Keys
      Press Shift+key combination.
      Specified by:
      shift in interface Keys
    • meta

      public Keys meta(String key)
      Description copied from interface: Keys
      Press Meta/Command+key combination.
      Specified by:
      meta in interface Keys