Method: Ferrum::Keyboard#type

Defined in:
lib/ferrum/keyboard.rb

#type(*keys) ⇒ self

Sends a keydown, keypress/input, and keyup event for each character in the text.

Parameters:

  • keys (Array<String, Symbol, (Symbol, String)>)

    The text to type into a focused element, ‘[:Shift, “s”], “tring”`.

Returns:

  • (self)


71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ferrum/keyboard.rb', line 71

def type(*keys)
  keys = normalize_keys(Array(keys))

  keys.each do |key|
    type = key[:text] ? "keyDown" : "rawKeyDown"
    @page.command("Input.dispatchKeyEvent", type: type, **key)
    @page.command("Input.dispatchKeyEvent", slowmoable: true, type: "keyUp", **key)
  end

  self
end