简体   繁体   中英

Select Item of Spinner error in Robotium

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM