Renamed keyevent to press_keycode and added long_press_keycode. · smallsharp/python-client@2d25554 · GitHub
Skip to content

Commit 2d25554

Browse files
author
Payman Delshad
committed
Renamed keyevent to press_keycode and added long_press_keycode.
1 parent d215b97 commit 2d25554

4 files changed

Lines changed: 30 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion

appium/webdriver/mobilecommand.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class MobileCommand(object):
2222

2323
# Appium Commands
2424
GET_APP_STRINGS = 'getAppStrings'
25-
KEY_EVENT = 'keyEvent'
25+
PRESS_KEYCODE = 'pressKeyCode'
26+
LONG_PRESS_KEYCODE = 'longPressKeyCode'
2627
GET_CURRENT_ACTIVITY = 'getCurrentActivity'
2728
SET_IMMEDIATE_VALUE = 'setImmediateValue'
2829
PULL_FILE = 'pullFile'

appium/webdriver/webdriver.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def hide_keyboard(self, key_name=None):
337337
self.execute(Command.HIDE_KEYBOARD, data)
338338
return self
339339

340-
def keyevent(self, keycode, metastate=None):
340+
def press_keycode(self, keycode, metastate=None):
341341
"""Sends a keycode to the device. Android only. Possible keycodes can be
342342
found in http://developer.android.com/reference/android/view/KeyEvent.html.
343343
@@ -353,6 +353,22 @@ def keyevent(self, keycode, metastate=None):
353353
self.execute(Command.KEY_EVENT, data)
354354
return self
355355

356+
def long_press_keycode(self, keycode, metastate=None):
357+
"""Sends a long press of keycode to the device. Android only. Possible keycodes can be
358+
found in http://developer.android.com/reference/android/view/KeyEvent.html.
359+
360+
:Args:
361+
- keycode - the keycode to be sent to the device
362+
- metastate - meta information about the keycode being sent
363+
"""
364+
data = {
365+
'keycode': keycode
366+
}
367+
if metastate != None:
368+
data['metastate'] = metastate
369+
self.execute(Command.LONG_PRESS_KEYCODE, data)
370+
return self
371+
356372
@property
357373
def current_activity(self):
358374
"""Retrieves the current activity on the device.
@@ -519,8 +535,10 @@ def _addCommands(self):
519535
('POST', '/session/$sessionId/touch/multi/perform')
520536
self.command_executor._commands[Command.GET_APP_STRINGS] = \
521537
('GET', '/session/$sessionId/appium/app/strings')
522-
self.command_executor._commands[Command.KEY_EVENT] = \
523-
('POST', '/session/$sessionId/appium/device/keyevent')
538+
self.command_executor._commands[Command.PRESS_KEYCODE] = \
539+
('POST', '/session/$sessionId/appium/device/press_keycode')
540+
self.command_executor._commands[Command.LONG_PRESS_KEYCODE] = \
541+
('POST', '/session/$sessionId/appium/device/long_press_keycode')
524542
self.command_executor._commands[Command.GET_CURRENT_ACTIVITY] = \
525543
('GET', '/session/$sessionId/appium/device/current_activity')
526544
self.command_executor._commands[Command.SET_IMMEDIATE_VALUE] = \

test/functional/android/appium_tests.py

Lines changed: 6 additions & 2 deletions

0 commit comments

Comments
 (0)