Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions appium/webdriver/mobilecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class MobileCommand(object):
# Appium Commands
GET_APP_STRINGS = 'getAppStrings'
PRESS_KEYCODE = 'pressKeyCode'
KEY_EVENT = 'keyEvent' # Needed for Selendroid
LONG_PRESS_KEYCODE = 'longPressKeyCode'
GET_CURRENT_ACTIVITY = 'getCurrentActivity'
SET_IMMEDIATE_VALUE = 'setImmediateValue'
Expand Down
20 changes: 20 additions & 0 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,23 @@ def hide_keyboard(self, key_name=None, key=None, strategy=None):
self.execute(Command.HIDE_KEYBOARD, data)
return self

# Needed for Selendroid
def keyevent(self, keycode, metastate=None):
"""Sends a keycode to the device. Android only. Possible keycodes can be
found in http://developer.android.com/reference/android/view/KeyEvent.html.

:Args:
- keycode - the keycode to be sent to the device
- metastate - meta information about the keycode being sent
"""
data = {
'keycode': keycode,
}
if metastate is not None:
data['metastate'] = metastate
self.execute(Command.KEY_EVENT, data)
return self

def press_keycode(self, keycode, metastate=None):
"""Sends a keycode to the device. Android only. Possible keycodes can be
found in http://developer.android.com/reference/android/view/KeyEvent.html.
Expand Down Expand Up @@ -640,6 +657,9 @@ def _addCommands(self):
('POST', '/session/$sessionId/touch/multi/perform')
self.command_executor._commands[Command.GET_APP_STRINGS] = \
('POST', '/session/$sessionId/appium/app/strings')
# Needed for Selendroid
self.command_executor._commands[Command.KEY_EVENT] = \
('POST', '/session/$sessionId/appium/device/keyevent')
self.command_executor._commands[Command.PRESS_KEYCODE] = \
('POST', '/session/$sessionId/appium/device/press_keycode')
self.command_executor._commands[Command.LONG_PRESS_KEYCODE] = \
Expand Down