UiAutomator元素缺失

时间:2019-05-20 08:54:27

标签: android uiautomator

在android pi平台上,有时UiAutomator无法找到所有可用的ui元素。

有时手动按下和向上即可解决此问题,即刷新测试过的用户界面。

<node index="0" text="" resource-id="com.passmark.pt_mobile:id/benchmarkLayout" class="android.widget.LinearLayout" package="com.passmark.pt_mobile" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,112][1080,1920]">
<node index="0" text="" resource-id="android:id/list" class="android.widget.ExpandableListView" package="com.passmark.pt_mobile" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="true" scrollable="true" long-clickable="false" password="false" selected="false" bounds="[0,112][1080,1727]">
    <node index="11" text="" resource-id="" class="android.widget.RelativeLayout" package="com.passmark.pt_mobile" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[12,1036][1068,1118]">
        <node index="1" text="250 MBytes / Sec." resource-id="com.passmark.pt_mobile:id/result" class="android.widget.TextView" package="com.passmark.pt_mobile" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[821,1074][1048,1118]" />
                      </node>
    <node index="12" text="" resource-id="" class="android.widget.RelativeLayout" package="com.passmark.pt_mobile" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[12,1120][1068,1202]">
        <node index="0" text="Memory Read Uncached" resource-id="com.passmark.pt_mobile:id/test_label" class="android.widget.TextView" package="com.passmark.pt_mobile" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[32,1120][335,1158]" />
        <node index="1" text="247 MBytes / Sec." resource-id="com.passmark.pt_mobile:id/result" class="android.widget.TextView" package="com.passmark.pt_mobile" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[821,1158][1048,1202]" />
                      </node>
    <node index="13" text="" resource-id="" class="android.widget.RelativeLayout" package="com.passmark.pt_mobile" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[12,1204][1068,1286]">
        <node index="0" text="Memory Write" resource-id="com.passmark.pt_mobile:id/test_label" class="android.widget.TextView" package="com.passmark.pt_mobile" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[32,1204][206,1242]" />
    <node index="1" text="251 MBytes / Sec." resource-id="com.passmark.pt_mobile:id/result" class="android.widget.TextView" package="com.passmark.pt_mobile" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[821,1242][1048,1286]" />
                      </node>

UiDevice.dumpWindowHierarchy(new File(xmlLocation))中,某些元素丢失了,我们可以看到索引'0'〜'10'丢失了。
但是当我停止自动测试时,手动打开UiAutomatorViewer,可以找到缺少的元素。
除了手动刷新外,我该如何解决此类问题?

0 个答案:

没有答案