Module: Appium::Core::Base::Device::KeyEvent

Included in:
Bridge::MJSONWP, Bridge::W3C
Defined in:
lib/appium_lib_core/common/device/keyevent.rb

Instance Method Summary collapse

Instance Method Details

#keyevent(key, metastate = nil) ⇒ Object

Only for Selendroid


21
22
23
24
25
# File 'lib/appium_lib_core/common/device/keyevent.rb', line 21

def keyevent(key, metastate = nil)
  args             = { keycode: key }
  args[:metastate] = metastate if metastate
  execute :keyevent, {}, args
end

#long_press_keycode(key, metastate: [], flags: []) ⇒ Object

Raises:

  • (ArgumentError)

38
39
40
41
42
43
44
45
46
47
# File 'lib/appium_lib_core/common/device/keyevent.rb', line 38

def long_press_keycode(key, metastate: [], flags: [])
  raise ArgumentError, 'flags should be Array' unless flags.is_a? Array
  raise ArgumentError, 'metastates should be Array' unless metastate.is_a? Array

  args             = { keycode: key }
  args[:metastate] = metastate.reduce(0) { |acc, meta| acc | meta } unless metastate.empty?
  args[:flags]     = flags.reduce(0) { |acc, flag| acc | flag } unless flags.empty?

  execute :long_press_keycode, {}, args
end

#press_keycode(key, metastate: [], flags: []) ⇒ Object

Raises:

  • (ArgumentError)

27
28
29
30
31
32
33
34
35
36
# File 'lib/appium_lib_core/common/device/keyevent.rb', line 27

def press_keycode(key, metastate: [], flags: [])
  raise ArgumentError, 'flags should be Array' unless flags.is_a? Array
  raise ArgumentError, 'metastates should be Array' unless metastate.is_a? Array

  args             = { keycode: key }
  args[:metastate] = metastate.reduce(0) { |acc, meta| acc | meta } unless metastate.empty?
  args[:flags]     = flags.reduce(0) { |acc, flag| acc | flag } unless flags.empty?

  execute :press_keycode, {}, args
end