In this article we are going to see how to press hardware keys of an Android device while performing Unit Testing using robotium framework.Now a days, most of the device do not have hardware keys. But, Android handles those keys separately than soft keys.
After Initiating solo, we need to use the object of solo.
-To press Up button
solo.sendKey(Solo.UP);
-To press Down
solo.sendKey(Solo.DOWN);
-To press Back button
solo.goBack();
-To press Right
solo.sendKey(Solo.RIGHT);
-To press Left
solo.sendKey(Solo.LEFT);
-To press Enter(Like pressing ok)
solo.sendKey(Solo.ENTER);
-To press Menu
solo.sendKey(Solo.MENU);
-To press Delete
solo.sendKey(Solo.DELETE);
Note ; All of them represents a integer value
RIGHT = 22
LEFT =21
UP=19
DOWN=20
ENTER=66
MENU=82
DELETE =67
If we integer value in place of that static code, it will work perfectly. Like in case of pressing UP
solo.sendKey(19);
Thanks...:)
After Initiating solo, we need to use the object of solo.
-To press Up button
solo.sendKey(Solo.UP);
-To press Down
solo.sendKey(Solo.DOWN);
-To press Back button
solo.goBack();
-To press Right
solo.sendKey(Solo.RIGHT);
-To press Left
solo.sendKey(Solo.LEFT);
-To press Enter(Like pressing ok)
solo.sendKey(Solo.ENTER);
-To press Menu
solo.sendKey(Solo.MENU);
-To press Delete
solo.sendKey(Solo.DELETE);
Note ; All of them represents a integer value
RIGHT = 22
LEFT =21
UP=19
DOWN=20
ENTER=66
MENU=82
DELETE =67
If we integer value in place of that static code, it will work perfectly. Like in case of pressing UP
solo.sendKey(19);
Thanks...:)