我试过了多个选项。两者都不适合我。是否可以使用uiautomator选择微调元件?用uiautomator选择一个微调元件
代码示例:
UiObject spinner = mDevice.findObject(new UiSelector().className("android.widget.Spinner")
.instance(0));
try {
Integer cnt = spinner.getChildCount();
if (cnt > 0) {
UiObject item = spinner.getChild(new UiSelector().index(cnt-1));
item.click();
}
} catch (UiObjectNotFoundException e){}
而不是使用UI自动化,你需要使用espresso库:http://stackoverflow.com/questions/31420839/android-espresso-check-selected-spinner-text –