Select Item of Spinner error in Robotium

Issue

I make a UI Test that contains a Spinner. When I execute:

  solo.clickOnView(solo.getView(R.id.spinner_editwebsite));

The spinner can show the options,but can not select the options then the test stopped!

Then an error occurred!

I try to add

`solo.pressSpinnerItem(0,1);` 

behind the

`solo.clickOnView(solo.getView(R.id.spinner_editwebsite));`

but not work!

Solution

take a look at this answer:

Seems they took those classes out now. Just ran into this myself but found a way to do this properly and generically.

// 0 is the first spinner in the layout
View view1  solo.getView(Spinner.class, 0);
solo.clickOnView(view1);
solo.scrollToTop(); // I put this in here so that it always keeps the list at start
// select the 10th item in the spinner
solo.clickOnView(solo.getView(TextView.class, 10));

From: How do I click the first item in a spinner using Robotium?

As you can see a method which you try to use seems to be depracated. Try to use code above instead of yours.

Hope it help

Answered By – piotrek1543

Leave a Comment