Search code examples
robotiummonkeyrunner

Can a command from monkey runner be used in robotium?


I have written a script in robotium which works just fine, but our application is designed in such a way that it has to interact with the Native android application which cannot be resigned. I have to click a button on the native app which cant be done through robotium. So i wanted to know if i can add a command of monkey runner in my script to click on the app.


Solution

  • solo.sendKey(20); // used for move to next object on screen //
    

    Execute above line and stop when you get focus on your desired button

    Then execute bellow line, to click on button

    solo.sendKey(66); // Click On Focused Button //
    

    For example you have 3 Objects On Screen:

    [1] username [ text box ]

    [2] password [ text box ]

    [3] Submit [ Button ]

    If you want to Click on " Submit " button using "robotium" then

    solo.sendKey(20);// focus on username textbox
    solo.sendKey(20);// focus on password textbox
    solo.sendKey(20);// focus on Submit button
    solo.sendKey(66);// Click On Submit Button
    

    generally we send keyevents from munkey code, so i suggest you above code.

    Note:

    KEYCODE_DPAD_DOWN [ Constant Value: 20 (0x00000014) ]

    KEYCODE_ENTER [ Constant Value: 66 (0x00000042) ]

    Pasted from http://developer.android.com/reference/android/view/KeyEvent.html

    I tested this on my automation application.

    I hope this will help you, Thanks.