Hey! I’m working on adding a robust baseline profi...
# testing
j
Hey! I’m working on adding a robust baseline profile to my Wear OS app. I’m running into a strange issue where sometimes
device.findObject(By.res(…))
returns null. I can see all queried elements are on screen. I haven’t seen any documentation mentioning that this methods behaves in a best effort fashion. Has anyone experienced this before or know why this happens? I’ve not been able to determine a rhyme or reason for this behavior. Here, is an excerpt from my StartupBaselineProfile that’s through an exception:
Copy code
device.findObject(By.res(UiTestingTags.HMOBatterView)).also { batterView ->
    device.wait(Until.hasObject(By.res(UiTestingTags.HMOBatterViewBalls)), 10_000)
    // Increment the number of balls until the "walk" dialog displays.
    batterView.findObject(By.res(UiTestingTags.HMOBatterViewBalls)).also { ballsButton ->
        ...
    }
}
Specifically the NPE happens:
batterView.findObject(By.res(UiTestingTags.HMOBatterViewBalls))
I performed a clean and rebuild and the code ran without exception. I’m not sure if this is a factor in the matter but I’m testing on a WearOS emulator (Wear OS Large Round API 33)