Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the 3rd argument of monkeyrunner.press

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 sdk doc that press only contain two argument. is it problem caused by new version SDK tool.

like image 536
Nancy Avatar asked Jul 15 '11 08:07

Nancy


3 Answers

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

like image 77
n8schloss Avatar answered Nov 09 '22 08:11

n8schloss


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");
...
}
like image 25
Xiao Avatar answered Nov 09 '22 09:11

Xiao


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.

like image 1
Android Boy Avatar answered Nov 09 '22 09:11

Android Boy