appium怎么操作手机按键
1个回答
展开全部
有这样的函数:press_keycode
用python举例来说,是这样定义的
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.
: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.PRESS_KEYCODE, data)
return self
实际使用的时候,比我想按 “音量键上”,根据keycode表,可得知音量键上的值为24
KEYCODE_VOLUME_UP 音量增加键 24
那么代码中直接这样即可 driver.press_keycode(24)
用python举例来说,是这样定义的
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.
: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.PRESS_KEYCODE, data)
return self
实际使用的时候,比我想按 “音量键上”,根据keycode表,可得知音量键上的值为24
KEYCODE_VOLUME_UP 音量增加键 24
那么代码中直接这样即可 driver.press_keycode(24)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询