Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webview of main app incorrectly flagged as zero pages when related browser app's webview has zero pages #888

Open
pandabat opened this issue Dec 1, 2023 · 0 comments

Comments

@pandabat
Copy link

pandabat commented Dec 1, 2023

I've come across an odd issue that I can't fully explain with this. Running automation tests via robot framework using pip modules/packages listed in Environment section below.

Recently upgraded the test machines for Fedora 39 and updated all automation tools to latest.

Afterwards we started seeing regular failures (not always but almost always) on units just after a browser webview app separate (but related) to our main webview app had been closed. Our main app launches the browser app (a separate apk), which opens its own webview, while the main app stays open/active/alive in the background. The browser was being tested using native context and the tests were attempting to switch back to the chrome webview context of the main app.

The tests were failing with a "NoSuchContextException: Message: No such context found" error. This can be see in the attached appium log at 2023-12-01 20:00:48:243. The reason that the main app's webview is not listed is given in the attached appium log as being due to the fact that it reported having zero pages.

appium_zero_page_webview.log

(note the provided log is from a test run where the empty browser webview is present at the start of the tests so the failure comes sooner and the logs are shorter)

However I ran a script in parallel to the appium tests and the webview for the main app is not empty at the time of the failure nor is it ever populated as empty (following is from querying the webview info in the same way as https://github.com/appium/appium-android-driver/blob/master/lib/helpers/webview.ts#L351 and using the same adb executable as appium does).

INFO FOR WEBVIEW webview_devtools_remote_4867

{ "Android-Package": "com.mycompany.ourmainapp", "Browser": "Chrome/119.0.6045.163", "Protocol-Version": "1.3", "User-Agent": "Mozilla/5.0 (Linux; Android 7.1.2; p212 Build/NHG47L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/119.0.6045.163 Safari/537.36", "V8-Version": "11.9.169.6", "WebKit-Version": "537.36 (@e87d8ea31f029f62cebd71af35a9059e00c18d1e)", "webSocketDebuggerUrl": "ws://127.0.0.1:12345/devtools/browser" }

[ { "description": "{\"attached\":true,\"empty\":false,\"height\":1080,\"never_attached\":false,\"screenX\":0,\"screenY\":0,\"visible\":true,\"width\":1920}", "devtoolsFrontendUrl": "https://chrome-devtools-frontend.appspot.com/serve_rev/@e87d8ea31f029f62cebd71af35a9059e00c18d1e/inspector.html?ws=127.0.0.1:12345/devtools/page/A695EA9671A465380E4CA97C3B286ADC", "faviconUrl": "https://localhost/favicon.ico", "id": "A695EA9671A465380E4CA97C3B286ADC", "title": "ourmainapp", "type": "page", "url": "https://localhost/index.html/", "webSocketDebuggerUrl": "ws://127.0.0.1:12345/devtools/page/A695EA9671A465380E4CA97C3B286ADC" } ]

INFO FOR WEBVIEW webview_devtools_remote_5807

{ "Android-Package": "com.mycompany.browser", "Browser": "Chrome/119.0.6045.163", "Protocol-Version": "1.3", "User-Agent": "Mozilla/5.0 (Linux; Android 7.1.2; p212 Build/NHG47L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/119.0.6045.163 Safari/537.36", "V8-Version": "11.9.169.6", "WebKit-Version": "537.36 (@e87d8ea31f029f62cebd71af35a9059e00c18d1e)", "webSocketDebuggerUrl": "ws://127.0.0.1:12345/devtools/browser" }

[ ]

The browser app's webview is indeed empty at this time though and it appears as though the presence of this empty browser webview is somehow affecting the interpretation of the main app's webview page info. Since querying the webview info directly using the same methodology and same adb executable as Appium clearly shows that the main app's webview is not empty, I am unsure as to where this is going wrong internally to the Android driver but that seems to be the case.

The above logs are from an Android 7 STB (with Chrome 119 webview) but we also see exactly the same issue on an Android 11 terminal device running same webview. Downgrading to 117 webview didn't help.

To further muddy the waters, I cannot reproduce this issue on another machine running Fedora 38. As far as I can ascertain, it has all the same environment as below with the obvious exception of the OS (Fedora 38 instead of 39) and python (v3.11.6 instead of v3.12.0). It never gives this issue when running the same tests against the same devices.

Environment is as follows:
os name: NAME="Fedora Linux"
os version: VERSION="39 (Workstation Edition)"
appium: 2.2.2
appium-doctor: 2.0.28
appium driver:
✔ Listing installed drivers

(pip modules/packages)
Appium-Python-Client 3.1.0
robotframework 6.1.1
robotframework-appiumlibrary 2.0.0
robotframework-pythonlibcore 4.3.0
robotframework-seleniumlibrary 6.2.0
robotframework-sshlibrary 3.8.0
selenium 4.15.2
wheel 0.42.0

google-chrome: Google Chrome 119.0.6045.159
/usr/bin/chromedriver: ChromeDriver 119.0.6045.105 (38c72552c5e15ba9b3117c0967a0fd105072d7c6-refs/branch-heads/6045@{#1103})
/usr/local/bin/chromedriver: ChromeDriver 119.0.6045.105 (38c72552c5e15ba9b3117c0967a0fd105072d7c6-refs/branch-heads/6045@{#1103})
~/.appium/.../chromedriver/linux/: chromedriver-linux64_v119.0.6045.105

Python version v3.12.0

android sdk:
Installed packages:=====================] 100% Fetch remote repository...

Path Version Description Location
build-tools;29.0.2 29.0.2 Android SDK Build-Tools 29.0.2 build-tools/29.0.2
build-tools;30.0.2 30.0.2 Android SDK Build-Tools 30.0.2 build-tools/30.0.2
build-tools;30.0.3 30.0.3 Android SDK Build-Tools 30.0.3 build-tools/30.0.3
build-tools;32.0.0 32.0.0 Android SDK Build-Tools 32 build-tools/32.0.0
build-tools;33.0.0 33.0.0 Android SDK Build-Tools 33 build-tools/33.0.0
build-tools;33.0.2 33.0.2 Android SDK Build-Tools 33.0.2 build-tools/33.0.2
cmake;3.18.1 3.18.1 CMake 3.18.1 cmake/3.18.1
cmake;3.22.1 3.22.1 CMake 3.22.1 cmake/3.22.1
emulator 32.1.15 Android Emulator emulator
ndk;21.0.6113669 21.0.6113669 NDK (Side by side) 21.0.6113669 ndk/21.0.6113669
patcher;v4 1 SDK Patch Applier v4 patcher/v4
platform-tools 34.0.5 Android SDK Platform-Tools platform-tools
platforms;android-29 5 Android SDK Platform 29 platforms/android-29
platforms;android-30 3 Android SDK Platform 30 platforms/android-30
platforms;android-31 1 Android SDK Platform 31 platforms/android-31
platforms;android-32 1 Android SDK Platform 32 platforms/android-32
platforms;android-33 3 Android SDK Platform 33 platforms/android-33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant