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

0
0

I am having problems scrolling up in a spinner to select the first item in a Robotium test case. Here is my code:

int pos = solo.getCurrentSpinners().get(0).getSelectedItemPosition();
solo
.pressSpinnerItem(0, 0 - pos);

pos is 1 when I debug, but Robotium still presses the spinner on index 1 even though I order it to press on -1. What am I doing wrong?

Thanks
Markus

  • You must to post comments
0
0

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));
  • 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