在Robotium中选择Spinner错误项

时间:2016-01-06 09:43:21

标签: android robotium android-testing ui-testing

我制作了一个包含Spinner的UI测试。当我执行:

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

微调器可以显示选项,但无法选择选项,然后测试停止!

然后发生错误!

我尝试添加

`solo.pressSpinnerItem(0,1);` 

背后的

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

但没有工作!

1 个答案:

答案 0 :(得分:1)

看看这个答案:

  

他们现在似乎把这些课程拿出来了。我自己也碰到了这个   找到了一种正确和一般地做到这一点的方法。

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

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

正如您所看到的,您尝试使用的方法似乎被删除了。 尝试使用上面的代码而不是你的代码。

希望有所帮助