I also had this issue and i couldn't find a solution with robotium. Then i move to the android instrumentation provided with the SDK. What i have done is mentioned below. This worked without any issues for me. Here it is ..
First define a private variable for the button as a member variable
private Button msButton;
Then get the button instance with in the setup method.
mButton = (Button) solo.getCurrentActivity().findViewById(
com.marakana.android.simple_intent.R.id.sendButton);
Then call the button click with in the UI thread in the test method as mentioned below.
//Test button method
public void testButtonClick() {
//Get the current activity and request to run onUI thread
solo.getCurrentActivity().runOnUiThread(new Runnable() {
public void run() {
//Request focus for the button
mButton.requestFocus();
}
});
//Send the button click event
this.sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
}
That's it .. Now you can test your button with other Robotium features.
Cheers !!!!!!!!
First define a private variable for the button as a member variable
private Button msButton;
Then get the button instance with in the setup method.
mButton = (Button) solo.getCurrentActivity().findViewById(
com.marakana.android.simple_intent.R.id.sendButton);
Then call the button click with in the UI thread in the test method as mentioned below.
//Test button method
public void testButtonClick() {
//Get the current activity and request to run onUI thread
solo.getCurrentActivity().runOnUiThread(new Runnable() {
public void run() {
//Request focus for the button
mButton.requestFocus();
}
});
//Send the button click event
this.sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
}
That's it .. Now you can test your button with other Robotium features.
Cheers !!!!!!!!
No comments:
Post a Comment