Method: Capybara::Node::Element#send_keys

Defined in:
lib/capybara/node/element.rb

#send_keys(keys, ...) ⇒ Capybara::Node::Element

Send Keystrokes to the Element.

Examples:

element.send_keys "foo"                     #=> value: 'foo'
element.send_keys "tet", :left, "s"         #=> value: 'test'
element.send_keys [:control, 'a'], :space   #=> value: ' ' - assuming ctrl-a selects all contents

Symbols supported for keys:

  • :cancel
  • :help
  • :backspace
  • :tab
  • :clear
  • :return
  • :enter
  • :shift
  • :control
  • :alt
  • :pause
  • :escape
  • :space
  • :page_up
  • :page_down
  • :end
  • :home
  • :left
  • :up
  • :right
  • :down
  • :insert
  • :delete
  • :semicolon
  • :equals
  • :numpad0
  • :numpad1
  • :numpad2
  • :numpad3
  • :numpad4
  • :numpad5
  • :numpad6
  • :numpad7
  • :numpad8
  • :numpad9
  • :multiply - numeric keypad *
  • :add - numeric keypad +
  • :separator - numeric keypad 'separator' key ??
  • :subtract - numeric keypad -
  • :decimal - numeric keypad .
  • :divide - numeric keypad /
  • :f1
  • :f2
  • :f3
  • :f4
  • :f5
  • :f6
  • :f7
  • :f8
  • :f9
  • :f10
  • :f11
  • :f12
  • :meta
  • :command - alias of :meta

Parameters:

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

Returns:



274
275
276
277
# File 'lib/capybara/node/element.rb', line 274

def send_keys(*args)
  synchronize { base.send_keys(*args) }
  self
end