Description
Issue
In some cases when trying to locate an element by xPath we run into the following issue.
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.accessibility.AccessibilityWindowInfo.getBoundsInScreen(android.graphics.Rect)' on a null object reference
The issue originates in the AxNodeInfoHelper.java class.
if (node.getWindow() != null) {
node.getWindow().getBoundsInScreen(window);
ret.intersect(window);
}
Between two node.getWindow()
calls the AccessibilityWindowInfo becomes null.
Stacktrace
https://gist.github.com/GeneraalGarnaal/72fa7ac55e7038ffb56974c7d03ddb6d#file-gistfile1-txt
Reproducibility
We are using io.appium.uiautomator2.server version 4.12.2
.
I realise that this is an older version but the problematic code is still present in the newest version.
I have not been able to reproduce it on a local setup because the issue does not happen consistently.
It depends on the timing of the AccessibilityWindowInfo changing.
The issue has happened on different devices but mostly on a Samsung Galaxy A13 running Android 13.
This has also been reported earlier: appium/appium#11513 (comment).
Thank you in advance! Let me know if you need some extra information.