3

I'm using the robotium. Today I ran into with little problem. After click on button application crosses to the next activity. I need wait for appearance some button.

View am = solo.getView(R.id.btn_login);

solo.waitForCondition(am.isShown(), 5000);

This code doesn't work.

It also doesn't work if am is identified like

Button am = solo.getButton(R.id.btn_login);

Help me please figure it out!

mmBs
  • 8,421
  • 6
  • 38
  • 46
ELEGANCE
  • 31
  • 1
  • 2

3 Answers3

6

You've to implement the Condition interface:

solo.waitForCondition(new Condition() {
   @Override
   public boolean isSatisfied() {
       return am.isShown();
   }
}, 5000);

In isSatisfied() you are quite free to test whatever you need :)

Trinimon
  • 13,839
  • 9
  • 44
  • 60
0

isShown() in Android is very often misunderstood. It returns true, when view and all of its ancestors are visible.

I think you could just try:

solo.waitForView(...)
maszter
  • 3,680
  • 6
  • 37
  • 53
0

In Robotium, there are different waitForCondition. Such as:

solo.waitForView() //if a certain view is shown after the load screen is done.
solo.waitForDialogToClose() //waits for the dialog to close
solo.waitForActivity() // if there is a activity change
solo.waitForText() //if a certain text appears after the loading is done

In your case, since you know the id of the waited item, you can try:

solo.waitForView(R.id.btn_login, 5000);
mlchen850622
  • 668
  • 6
  • 7