开发者

What's the 3rd argument of monkeyrunner.press

开发者 https://www.devze.com 2023-03-20 23:24 出处:网络
After SDK tool upgrade to revision 12, When I connect to monkeyrunner and use press method like device.press(\'KEYCODE_HOME\',\'DOWN\')

After SDK tool upgrade to revision 12, When I connect to monkeyrunner and use press method like device.press('KEYCODE_HOME','DOWN') Will get error msg

Traceback(most recent call last): File "", line 1, in TypeError:press:The 3rd argument is required.

But I checkde 开发者_JAVA技巧sdk doc that press only contain two argument. is it problem caused by new version SDK tool.


To press a key using monkey runner you need to use something like device.press('KEYCODE_HOME',MonkeyDevice.DOWN_AND_UP) you shouldn't need to add a 3rd argument.

Perhaps your issue was that you were using 'DOWN' instead of MonkeyDevice.DOWN


Actually the third argument is also a string indicating the press type. It is a constant in MonkeyDevice: DOWN, UP and DOWN_AND_UP

If you do not want to import MonkeyDevice to only use it on this, the correct string which would be used in Monkeyrunner should be 'down', 'up' and 'downAndUp'.

They are defined in enum class ChimpChat.TouchPressType. Here below is its partial source code:

public enum TouchPressType {
    DOWN("down"), UP("up"), DOWN_AND_UP("downAndUp");
...
}


To press a key using monkey runner you need to use something like device.press('KEYCODE_HOME','DOWN',' ') you didn't get the any error.

The 3rd argument will be blank here.


You need to add MonkeyDevice

For example a paste command would look like this.

device.press('KEYCODE_PASTE',MonkeyDevice.DOWN)
0

精彩评论

暂无评论...
验证码 换一张
取 消