Select Robotium 中的 Spinner 错误项目
Select Item of Spinner error in Robotium
我做了一个 UI 测试,其中包含一个 Spinner
。当我执行时:
solo.clickOnView(solo.getView(R.id.spinner_editwebsite));
微调器可以显示选项,但不能select选项然后测试停止!
然后发生错误!
我尝试添加
`solo.pressSpinnerItem(0,1);`
在
后面
`solo.clickOnView(solo.getView(R.id.spinner_editwebsite));`
但是不行!
看看这个答案:
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?
如您所见,您尝试使用的方法似乎已被贬低。
尝试使用上面的代码而不是你的代码。
希望对您有所帮助
我做了一个 UI 测试,其中包含一个 Spinner
。当我执行时:
solo.clickOnView(solo.getView(R.id.spinner_editwebsite));
微调器可以显示选项,但不能select选项然后测试停止!
然后发生错误!
我尝试添加
`solo.pressSpinnerItem(0,1);`
在
后面`solo.clickOnView(solo.getView(R.id.spinner_editwebsite));`
但是不行!
看看这个答案:
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?
如您所见,您尝试使用的方法似乎已被贬低。 尝试使用上面的代码而不是你的代码。
希望对您有所帮助