Ok, I'll give it a try.
Android UiAutomator has a method called setCompressedLayoutHierarchy:
/**
* Enables or disables layout hierarchy compression.
*
* If compression is enabled, the layout hierarchy derived from the Acessibility
* framework will only contain nodes that are important for uiautomator
* testing. Any unnecessary surrounding layout nodes that make viewing
* and searching the hierarchy inefficient are removed.
*
* @param compressed true to enable compression; else, false to disable
* @since API Level 18
*/
public void setCompressedLayoutHeirarchy(boolean compressed) {
getAutomatorBridge().setCompressedLayoutHierarchy(compressed);
}
So.... when that is set, every single UiAutomator command runs on a subset of all the views that are actually present. That makes lookups and traversals of the layout hierarchy faster, since there's less elements to check on every operation.
I opened up the Android ApiDemos app and called getSource()
. Then I set ignoreUnimportantElements
to true
and ran it again.
See how less is returned when the layout is compressed? A bunch of nested FrameLayout and LinearLayout views were removed since they don't seem to actually contain anything important.
Things will run faster, but if you wanted to query the hierarchy for one of the "dropped" views, appium wouldn't see it, or xpath might grab the wrong element instead. That's why it's disabled by default. I would try enabling it and see what fails.