Getting started with Robotium. EditText not found

0
0

I just getting started with Robotium, writing my first test and I’m getting this weird error:

junit.framework.AssertionFailedError: 2131165500 EditTexts are not found!

This is my my test case

public class TestRegistrationActivity extends ActivityInstrumentationTestCase2<RegistrationActivity>{
private Solo solo;
public TestRegistrationActivity() {
super(RegistrationActivity.class);
}
public void setUp() throws Exception {
solo
= new Solo(getInstrumentation(), getActivity());
}
@Override
public void tearDown() throws Exception {
solo
.finishOpenedActivities();
}
@UiThreadTest
public void testSomeStuff(){
for (View v : solo.getCurrentViews()) {
Log.d(v.getClass().getSimpleName()+": "+v.getId());
}
solo
.getEditText(R.id.txtCountryCode);
}
}

And this is the log:

03-13 17:06:18.318: D/DEBUG(7907): EditText: 2131165500  
03-13 17:06:18.322: D/DEBUG(7907): PhoneEditText: 2131165501

As you can see:

  1. The solo.getCurrentViews() does indeed recognize that the view with id 2131165500 exists.
  2. The solo.getEditText(R.id.txtCountryCode) line always fails.

What could be wrong?

  • You must to post comments
0
0

Fixed.

The problem was that I thought solo.getEditText(int) took a View id as parameter. Instead it took the view’s index.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website