Skip to content

Commit ccbcaf8

Browse files
author
Payman Delshad
committed
Fix for #23: Re-add 'keyevent' temporarily.
1 parent a64da56 commit ccbcaf8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

appium/webdriver/mobilecommand.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class MobileCommand(object):
2323
# Appium Commands
2424
GET_APP_STRINGS = 'getAppStrings'
2525
PRESS_KEYCODE = 'pressKeyCode'
26+
# TODO: remove when new Appium is out
27+
KEY_EVENT = 'keyEvent'
2628
LONG_PRESS_KEYCODE = 'longPressKeyCode'
2729
GET_CURRENT_ACTIVITY = 'getCurrentActivity'
2830
SET_IMMEDIATE_VALUE = 'setImmediateValue'

appium/webdriver/webdriver.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,23 @@ def hide_keyboard(self, key_name=None):
340340
self.execute(Command.HIDE_KEYBOARD, data)
341341
return self
342342

343+
# TODO: remove when new Appium is out
344+
def keyevent(self, keycode, metastate=None):
345+
"""Sends a keycode to the device. Android only. Possible keycodes can be
346+
found in http://developer.android.com/reference/android/view/KeyEvent.html.
347+
348+
:Args:
349+
- keycode - the keycode to be sent to the device
350+
- metastate - meta information about the keycode being sent
351+
"""
352+
data = {
353+
'keycode': keycode,
354+
}
355+
if metastate is not None:
356+
data['metastate'] = metastate
357+
self.execute(Command.KEY_EVENT, data)
358+
return self
359+
343360
def press_keycode(self, keycode, metastate=None):
344361
"""Sends a keycode to the device. Android only. Possible keycodes can be
345362
found in http://developer.android.com/reference/android/view/KeyEvent.html.
@@ -538,6 +555,9 @@ def _addCommands(self):
538555
('POST', '/session/$sessionId/touch/multi/perform')
539556
self.command_executor._commands[Command.GET_APP_STRINGS] = \
540557
('POST', '/session/$sessionId/appium/app/strings')
558+
# TODO: remove when new Appium is out
559+
self.command_executor._commands[Command.KEY_EVENT] = \
560+
('POST', '/session/$sessionId/appium/device/keyevent')
541561
self.command_executor._commands[Command.PRESS_KEYCODE] = \
542562
('POST', '/session/$sessionId/appium/device/press_keycode')
543563
self.command_executor._commands[Command.LONG_PRESS_KEYCODE] = \

0 commit comments

Comments
 (0)