Android - Not able to inspect the UI elements from the Microsoft login webview

We are trying to automate some tests on an Android app using Appium and we are not able at all to inspect/identify the UI elements from the Microsoft login webview. I can see only the webview and that’s it.

The issue is reproducing only on a real devices, on emulator it is working fine.

  • Devices: Samsung Galaxy Tab Active 3, Lenovo Tab M10 Plus
  • Android Version: 10
  • Appium GUI and server version 1.21

I found a related issue opened on stack overflow - https://stackoverflow.com/questions/65355614/appium-android-not-able-to-find-the-login-elements/68622334#68622334

Last comment in your link should fix problem.

Hi @Aleksei! Thank you for your response.

I tried this solution and Appium does not see the webview context. Here are the logs.

[debug] [W3C (c53f8b7c)] Calling AppiumDriver.getContexts() with args: [“c53f8b7c-b541-42fc-982a-d4a940f61fe9”]
[debug] [AndroidDriver] Getting a list of available webviews
[debug] [ADB] Running ‘/Users/username/Library/Android/sdk/platform-tools/adb -P 5037 -s R52R30LYCTE shell cat /proc/net/unix’
[debug] [AndroidDriver] Found no active devtools sockets
[debug] [AndroidDriver] Other sockets are: [
[debug] [AndroidDriver] “0000000000000000: 00000002 00000000 00010000 0001 01 1513472 com.android.internal.os.WebViewZygoteInit/01fe6026-78a5-4202-8a56-3480d6642aaf”,
[debug] [AndroidDriver] “0000000000000000: 00000002 00000000 00010000 0001 01 28083 EngineeringModeServiceSocket”,
[debug] [AndroidDriver] “0000000000000000: 00000002 00000000 00010000 0001 01 25230 Multiclient”,
[debug] [AndroidDriver] “0000000000000000: 00000002 00000000 00000000 0001 01 18417 local.socket.tzdaemon@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@”,
[debug] [AndroidDriver] “0000000000000000: 00000002 00000000 00010000 0001 01 26446 PACMSERVICE”,
[debug] [AndroidDriver] “0000000000000000: 00000002 00000000 00010000 0001 01 21062 VND_Multiclient”,
[debug] [AndroidDriver] “0000000000000000: 00000002 00000000 00010000 0005 01 1545587 jdwp-control”,
[debug] [AndroidDriver] “0000000000000000: 00000002 00000000 00010000 0001 01 21070 DeviceRootKeyService”,
[debug] [AndroidDriver] “0000000000000000: 00000002 00000000 00000000 0001 03 133103 DeviceRootKeyService”,
[debug] [AndroidDriver] “0000000000000000: 00000003 00000000 00000000 0001 03 28604 Multiclient”,
[debug] [AndroidDriver] “0000000000000000: 00000003 00000000 00000000 0005 03 1563723 jdwp-control”,
[debug] [AndroidDriver] “0000000000000000: 00000003 00000000 00000000 0001 03 25234 VND_Multiclient”,
[debug] [AndroidDriver] “0000000000000000: 00000003 00000000 00000000 0001 03 1515067 com.android.internal.os.WebViewZygoteInit/01fe6026-78a5-4202-8a56-3480d6642aaf”,
[debug] [AndroidDriver] “0000000000000000: 00000003 00000000 00000000 0001 03 49833 Multiclient”,
[debug] [AndroidDriver] “0000000000000000: 00000003 00000000 00000000 0005 03 1542038 jdwp-control”
[debug] [AndroidDriver] ]
[debug] [AndroidDriver] Found 0 webviews: []
[debug] [AndroidDriver] Available contexts: [“NATIVE_APP”]
[debug] [W3C (c53f8b7c)] Responding to client with driver.getContexts() result: [“NATIVE_APP”]

I also started the appium server with the chromdriver flag like this:
appium --chromedriver-executable /path/to/chromdriver

Can you see webView with chrome browser (running on computer) on phone connected via cable?

No = go to app developers and ask make webView debugabble in app.

Steps:
1 connect phone via cable to computer
2 run app on phone and open needed webView
3 start Chrome on computer and choose in menu debug webview on phone

The problem is that for Microsoft Login we are using the microsoft-authentication-library-for-android (GitHub - AzureAD/microsoft-authentication-library-for-android: Microsoft Authentication Library (MSAL) for Android) and we don’t have any access to the webview properties like making it debugabble or not.

I also opened the discussion on their side as well - Not able to inspect the UI elements from the Microsoft login webview · Issue #1476 · AzureAD/microsoft-authentication-library-for-android · GitHub

Appium can make magic while webView closed in app

Hey @Aleksei! I am not understanding your last comment. Can you give me an idea on how to make this work based on my latest comment?

ask app developer to make web view inside app debuggable

The problem is that for Microsoft Login we are using the microsoft-authentication-library-for-android (https://github.com/AzureAD/microsoft-authentication-library-for-android) and we don’t have any access to the webview properties like making it debugabble or not.

so ask there. you need automate it. ask how :slight_smile: make it webView debuggable or any workaround.

Finally the issues is fixed by the team managing the microsoft authentication library for android.
See the issue added on their github - https://github.com/AzureAD/microsoft-authentication-library-for-android/issues/1476