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

后端 未结 3 1708
误落风尘
误落风尘 2021-01-23 12:08

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).getS         


        
3条回答
  •  一个人的身影
    2021-01-23 12:36

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

提交回复
热议问题