I am using Robotium for android testing. I have a feature where if the user types into a edit text field and then presses the enter key he is taken to the next field. Now to test this in Robotium, I am able to insert text into the text field. But I do not know how to simulate the enter key press in Robotium. If anyone has idea on this please let me know. Also let me know if there are any other better testing methods available other than Robotium? Thank you for your help and time.
Asked
Active
Viewed 3,467 times
1 Answers
6
public class MyActivityViewTest extends ActivityInstrumentationTestCase2<MyActivityView> {
private Solo solo;
SynchronizationTest(String name) {
super("com.mypackage", MyActivityView.class);
setName(name);
}
@Override
protected void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
@MediumTest
public void testEnter() throws Exception {
solo.sendKey(Solo.ENTER);
}
}

pawelzieba
- 16,082
- 3
- 46
- 72
-
Oh Great. Thank you very much for this one. I have a Intent In my activity which opens up a image to view it. When I do it manually It opens up fine and i will be selecting from the list which is my preferred application to view it like the gallery, or any other photo viewer. But In Robotium I am not able to click on list of application pop up. I suspect that this is due to the fact that the pop up is from outside my application package. Is there a work around for this? ClickOnText, ClickOnButton does not work fine. – Vinod Jul 18 '11 at 09:15
-
As is in: http://code.google.com/p/robotium/wiki/QuestionsAndAnswers "the test project is locked to the targetPackage. Going outside of that target package is not allowed by the Android platform." – pawelzieba Jul 18 '11 at 09:30