0

I'm new to Robotium and Android testing, lately I tested iOS apps. Now I am testing Android application, and on the first Activity I enter email and password, so when it is done, I press the Enter button on the keyboard and the next activity should appear. How can I implement it in my test? I have this in the beginnihg of test:

    EditText etEnterEmail = (EditText) solo.getView(R.id.EditText01);
    solo.clearEditText(etEnterEmail);
    solo.enterText(etEnterEmail, "anna@gmail.com");

    EditText etEnterPassword = (EditText) solo.getView(R.id.editText2);
    solo.clearEditText(etEnterPassword);
    solo.enterText(etEnterPassword, "qwerty123");

How can I press the button Enter? When the test is running the keyboard doesn't even appear, strings are just appearing in EditTexts. Plase help me! I'm desperate!

Ann
  • 475
  • 1
  • 5
  • 14

2 Answers2

2

You can send it via

solo.sendKey(Solo.ENTER);

After that you can check whether your Activity is being displayed by asserting:

assertTrue(solo.waitForActivity(expectedClass.getSimpleName()));
Ben Weiss
  • 17,182
  • 6
  • 67
  • 87
  • I tried that, no reaction... Test stops and application closes, the next activity still doesn't appear... Maybe smth I should import? – Ann Apr 05 '12 at 12:02
  • I have added the code you want to add in order to wait for your expected activity to my answer above. – Ben Weiss Apr 05 '12 at 12:06
  • This means your activity is not being displayed within the default waiting time. – Ben Weiss Apr 05 '12 at 12:30
  • Is it normal that during the test(when EditTexts are compliting) the keyboard is not shown? Maybe that's why it can't press on Enter? Cause it doesn'f see it? – Ann Apr 05 '12 at 13:31
  • I found a solution. solo.clickOnView(etEnterPassword); solo.sendKey(Solo.ENTER); Thanks anyway! It's great that there are people who care! – Ann Apr 05 '12 at 13:51
0

if the keyboard doesn't show maybe try solo.TypeText()

tty if this code works for you:

EditText etEnterEmail = (EditText) solo.getView(R.id.EditText01);
solo.clearEditText(etEnterEmail);
solo.TypeText(etEnterEmail, "anna@gmail.com");

EditText etEnterPassword = (EditText) solo.getView(R.id.editText2);
solo.clearEditText(etEnterPassword);
solo.TypeText(etEnterPassword, "qwerty123");
solo.senkey(solo.ENTER);
solo.assertCurrentActivity("check for activity", your_activity.class) //your_activity ex: MainActivity,...
Jens Erat
  • 37,523
  • 16
  • 80
  • 96
Kais
  • 40
  • 10