UIAutomator2 with Appium 1.x on Mac
While testing an Android device/emulator with Appium I am finding that the pagesource of the webhybrid seems to get 'stuck'.
Our login process uses a 3rd party's api and webpages. We pull these into our app and let the user login. After successful login, the 3rd party sends a very tiny html page as confirmation. At roughly 40% of the time, this tiny page gets 'stuck' in the pagesource that is returned to Appium via driver.getpagesource(). In effect, until I cold-boot the emulator (restart of the application doesn't seem to fix the issue) I can no longer run my tests as none of my controls can be found in the pagesource. Appium is connecting to the device and is able to request the pagesource however it returns as the 'previous' pagesource. I have confirmed that I'm connecting to the correct webcontext and I have confirmed that there is only one webcontext available.
Please note that I've also found this behavior when opening a webpage outside of our normal React flow. Ie. opening google inside of our webhybrid or opening another simple html page inside of the currect session.
This is making testing Android incredibly frustrating as the tests work fine when I can get to the correct page source.
I can provide more details if needed but please let me know if anyone has seen this issue and more importantly, how to get around it.
I've tried checking the pagesource() to confirm the issue. I've confirmed that I am connecting to the correct webContext. I've confirmed there is only one webContext available. My tests work properly when the correct pagesource is available. This problem is intermittent and I cannot lock down exactly when or why it happens. UIAutomator2 version is up to date.