我正在使用Appium Inspector(与UiAutomator2)从Android应用程序中获取以下结构:
(...)
<android.widget.Spinner index="1" package="something.something" class="android.widget.Spinner" text="[object Object]" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[64,1016][106,1060]" displayed="true">
<android.widget.ListView index="0" package="something.something" class="android.widget.ListView" text="" resource-id="react-select-7--list" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,1174][720,1384]" displayed="true">
<android.view.View index="0" package="something.something" class="android.view.View" text="[object Object]" resource-id="react-select-7--option-0" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="true" long-clickable="false" password="false" scrollable="false" selected="true" bounds="[0,1174][720,1280]" displayed="true" />
<android.view.View index="1" package="something.something" class="android.view.View" text="[object Object]" resource-id="react-select-7--option-1" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,1278][720,1384]" displayed="true" />
<android.view.View index="2" package="something.something" class="android.view.View" text="[object Object]" resource-id="react-select-7--option-2" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,1382][720,1384]" displayed="true" />
<android.view.View index="3" package="something.something" class="android.view.View" text="[object Object]" resource-id="react-select-7--option-3" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,1382][720,1384]" displayed="true" />
<android.view.View index="4" package="something.something" class="android.view.View" text="[object Object]" resource-id="react-select-7--option-4" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,1382][720,1384]" displayed="true" />
<android.view.View index="5" package="something.something" class="android.view.View" text="[object Object]" resource-id="react-select-7--option-5" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,1382][720,1384]" displayed="true" />
<android.view.View index="6" package="something.something" class="android.view.View" text="[object Object]" resource-id="react-select-7--option-6" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,1382][720,1384]" displayed="true" />
</android.widget.ListView>
</android.widget.Spinner>
(...)
这似乎是列表视图的自定义实现,但我对此可能是错的。
问题是我可以在屏幕上看到列表中每个项目的文本,但无法从中获取文本(我使用[object Object]
得到了getText()
。
我做错什么了吗?有什么解决方法吗?
请注意,我已经检查了整个XML内容是否出现了我要查找的文本,并且该文本在任何地方都没有。我还仔细检查了上述XML表示的项目实际上就是列表中的项目。