I am trying to write a UiAutomator test case to check settings to see if Wi-Fi is enabled, and to turn it on if it is not.
The UI hierarchy for the Wi-Fi line in settings looks like:
LinearLayout (the entire Wi-Fi in settings)
--> (0) LinearLayout
----> ImageView (the Wi-Fi icon)
--> (1) LinearLayout
----> TextView ("Wi-Fi")
--> (2) Switch (the Wi-Fi toggle switch
My approach to identifying the correct switch is to find a switch where it's grandparent has a descendant text view containing the text "Wi-Fi".
There doesn't seem to be much information "out there" as to the grammar for constructing complex UiSelectors - can anyone point me in the right direction?