我正在使用 uiautomator 从 ListView 中选择文本。在横向模式下,它会滚动列表并找到该项目;但是,在纵向模式下,它找不到文本。ListView 在纵向模式下完全可见,因此不需要滚动,但这不应该导致错误吗?
UiScrollable listView = new UiScrollable(new UiSelector().scrollable(
true).className("android.widget.ListView"));
UiObject button1 = listView.getChildByText(new UiSelector()
.className(android.widget.CheckedTextView.class.getName()),
"Text");
button1.click();
错误如下:
com.android.uiautomator.core.UiObjectNotFoundException: for text= "Text"
at com.android.uiautomator.core.UiCollection.getChildByText(UiCollection.java:111)
at com.android.uiautomator.core.UiScrollable.getChildByText(UiScrollable.java:189)
at com.android.uiautomator.core.UiScrollable.getChildByText(UiScrollable.java:166)