We have the hybrid app fully covered by Appium tests which work well with UIAutomator 1 for native context as well as for WebView.
Unfortunately, based on many post and trials (e.g. here) looks like like UIAutomator 1 is not longer supported for newer Androids and doesn’t work in native context (neither xPath nor UISelector queries work).
From other hand UIAutomator2 works totally in different way. It fixes the Android 7 searches in native context but in WebView seems to be useless due to the UIObject2 usage which becomes stale quickly for fast changing UI.
For example with new UIAutomator2 I’m unable to reliably use getElementSize from WebdriverIO because from time to time it throws android.support.test.uiautomator.StaleObjectException .
That command gets elementID in first step and than uses it in size command like this:
[appium] [HTTP] --> GET /wd/hub/session/a8a3e663-8717-4d08-a7fd-a4a009cc3227/element/6be08f7a-3cee-4b6e-8a75-5e23ea3a9d0e/size {}
Unfortunately even if the queried element still exists, it’s not found, because in the meantime (matter of milliseconds) something else changed on the view.
So the question are:
- What is the best approach to tackle that issue ?
- Is there any possibility to still use old UIObject with UIAutomator2 ?