Android UiAutomator Referencing the Parent of a Parent

34 views Asked by At

After Updating from Android 12 to Android 13 I have problems in my Automation to select UiObjects. In Android 12 I had the following XmlForm in the APN Settings:

<node bounds="[72,270][1008,480]" checkable="false" checked="false" class="android.widget.RelativeLayout" clickable="false" content-desc="" enabled="true" focusable="false" focused="false" index="0" long-clickable="false" package="com.android.settings" password="false" resource-id="" scrollable="false" selected="false" text="" visible-to-user="true">
                                    <node bounds="[72,312][216,385]" checkable="false" checked="false" class="android.widget.TextView" clickable="false" content-desc="" enabled="true" focusable="false" focused="false" index="0" long-clickable="false" package="com.android.settings" password="false" resource-id="android:id/title" scrollable="false" selected="false" text="Name" visible-to-user="true"/>
                                    <node bounds="[72,385][315,438]" checkable="false" checked="false" class="android.widget.TextView" clickable="false" content-desc="" enabled="true" focusable="false" focused="false" index="1" long-clickable="false" package="com.android.settings" password="false" resource-id="android:id/summary" scrollable="false" selected="false" text="QA-1" visible-to-user="true"/>
                                  </node>

With this objextSelector: "objectSelector":{"text":"Name","fromParent":{"resourceId":"android:id/summary"}}} I was able to select the child by referencing the textfield of its sibling.

In Android13 the XMLform now looks like this:

<node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.android.settings" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" visible-to-user="true" bounds="[0,321][1080,526]">
  <node index="0" text="" resource-id="" class="android.widget.RelativeLayout" package="com.android.settings" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" visible-to-user="true" bounds="[72,321][1038,526]">
    <node index="0" text="" resource-id="com.android.settings:id/title_frame" class="android.widget.RelativeLayout" package="com.android.settings" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" visible-to-user="true" bounds="[72,363][238,431]">
      <node index="0" text="Name" resource-id="android:id/title" class="android.widget.TextView" package="com.android.settings" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" visible-to-user="true" bounds="[72,363][238,431]" />
    </node>
    <node index="1" text="Internet" resource-id="android:id/summary" class="android.widget.TextView" package="com.android.settings" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" visible-to-user="true" bounds="[72,431][238,484]" />
  </node>

The two fields I was using previously are no siblings anymore, therefore the old objectSelector obviously doesnt work anymore. My Assumption was just to jump one level up and look for the parent of the Parent like this: "objectSelector":{"text":"Name","fromParent":{"fromParent":{"resourceId":"android:id/summary"}}}

Unfortunately this doesnt work, can I not select the Parent of a Parent in UiAutomator? This would be weird since the other way around it works, if I go from the recycler_view where each setting is a child I get the the object with text="Internet" selected like this: "objectSelector":{"resourceId":"com.android.settings:id/recycler_view","childSelector":{"classNameMatches":"android.widget.LinearLayout","childSelector":{"index":"0","childSelector":{"index":"1"}}}}}

"objectSelector":{"resourceId":"com.android.settings:id/recycler_view","childSelector":{"classNameMatches":"android.widget.LinearLayout","childSelector":{"index":"0","childSelector":{"index":"0","childSelector":{"index":"0"}}}}}} -> and this Returns text="Name"

Why then can't I use it reversed?

My workaround for this Issue, is to click on the Uielement so another screen Pops up and then I can fetch the Value from the second screen, but this slows the automation down.

I tried multiple strings but as soon as I use the text="Name" and try to navigate through parents the Internet Object will not be selected.

0

There are 0 answers