Hello,
I have a hybrid android app, webview with a native navigation bar on top. I’m able to see both contexts without issue using
((SupportsContextSwitching) driver).getContextHandles();
but if I try to switch to the webview context
((SupportsContextSwitching) driver).context("WEBVIEW_my.package.name");
it hangs, no logs, eventually times out after 240 seconds. Only way I can continue the run is by tapping a native element (a button on my nav bar). For some reason the context then switches to webview and from that point on I can switch between context no problem.
I’ve incorporated this into my runs as a hacky fix, (first swtich tap nav bar) but I’m looking to address the issue now. Logs below, I’ve marked where the server hangs and the logs after it are where I tap the nav bar and the run continues without issues. I haven’t added detailed chromedriver logs. If anyoen thinks that would help, let me know and I’ll post them too
UPDATE: I believe I’ve found the root of the problem. My app spawns a second webview (which is necessary, a second domain is filled here when the user selects something). I removed this webview entirely and there is no issue. But I can’t see this empty webview in getContexts. Wonder is there still a way to solve this
btw, running appium using the below
appium server --allow-insecure chromedriver_autodownload
[AndroidUiautomator2Driver@7618 (f4b16c01)] Precalculated Chromedriver capabilities: {
[AndroidUiautomator2Driver@7618 (f4b16c01)] "androidPackage": "com.romypackage.rl.debug",
[AndroidUiautomator2Driver@7618 (f4b16c01)] "androidUseRunningApp": true,
[AndroidUiautomator2Driver@7618 (f4b16c01)] "androidProcess": "com.romypackage.rl.debug",
[AndroidUiautomator2Driver@7618 (f4b16c01)] "androidDeviceSerial": "37281FDJH00B62"
[AndroidUiautomator2Driver@7618 (f4b16c01)] }
[AndroidUiautomator2Driver@7618 (f4b16c01)] Before starting chromedriver, androidPackage is 'com.romypackage.rl.debug'
[Chromedriver@d388] Changed state to 'starting'
[Chromedriver@d388] Using the static Chromedriver->Chrome mapping
[Chromedriver@d388] The most recent known Chrome version: 127.0.6533
[Chromedriver@d388] Found 2 executables in '/Users/myname/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac'
[Chromedriver@d388] The following Chromedriver executables were found:
[Chromedriver@d388] '/Users/myname/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver-mac-x64_v127.0.6533.99' (version '127.0.6533.99', minimum Chrome version '127.0.6533')
[Chromedriver@d388] '/Users/myname/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver-mac-x64_v120.0.6099.109' (version '120.0.6099.109', minimum Chrome version '120.0.6099')
[Chromedriver@d388] Browser version in the supplied details: Chrome/127.0.6533.103
[Chromedriver@d388] Found Chrome bundle 'undefined' version '127.0.6533'
[Chromedriver@d388] Found 1 executable capable of automating Chrome '127.0.6533'.
Choosing the most recent, '/Users/myname/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver-mac-x64_v127.0.6533.99'.
[Chromedriver@d388] If a specific version is required, specify it with the `chromedriverExecutable`desired capability.
[Chromedriver@d388] Set chromedriver binary as: /Users/myname/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver-mac-x64_v127.0.6533.99
[Chromedriver@d388] Killing any old chromedrivers, running: pkill -15 -f "/Users/myname/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver-mac-x64_v127.0.6533.99.*--port=56118"
[Chromedriver@d388] No old chromedrivers seem to exist
[Chromedriver@d388] Cleaning this device's adb forwarded port socket connections: 37281FDJH00B62
[ADB] List forwarding ports
[ADB] Running '/Users/myname/Library/Android/sdk/platform-tools/adb -P 5037 -s 37281FDJH00B62 forward --list'
[Chromedriver@d388] Spawning chromedriver with: /Users/myname/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver-mac-x64_v127.0.6533.99 --port=56118 --adb-port=5037 --verbose
[Chromedriver@d388] ChromeDriver version: '127.0.6533.99'
[Chromedriver@d388] Set ChromeDriver communication protocol to W3C
[Chromedriver@d388] Matched '/status' to command name 'getStatus'
[Chromedriver@d388] Proxying [GET /status] to [GET http://127.0.0.1:56118/status] with no body
[Chromedriver@d388] connect ECONNREFUSED 127.0.0.1:56118
[Chromedriver@d388] Matched '/status' to command name 'getStatus'
[Chromedriver@d388] Proxying [GET /status] to [GET http://127.0.0.1:56118/status] with no body
[Chromedriver@d388] Got response with status 200: {"value":{"build":{"version":"127.0.6533.99 (f31af5097d90ef5ae5bd7b8700199bc6189ba34d-refs/branch-heads/6533@{#1910})"},"message":"ChromeDriver ready for new sessions.","os":{"arch":"x86_64","name":"Mac OS X","version":"14.6.1"},"ready":true}}
[Chromedriver@d388] Starting W3C Chromedriver session with capabilities: {
"capabilities": {
"alwaysMatch": {
"goog:chromeOptions": {
"androidPackage": "com.romypackage.rl.debug",
"androidUseRunningApp": true,
"androidProcess": "com.romypackage.rl.debug",
"androidDeviceSerial": "37281FDJH00B62"
},
"goog:loggingPrefs": {
"browser": "ALL"
}
}
}
}
[Chromedriver@d388] Matched '/session' to command name 'createSession'
[Chromedriver@d388] Proxying [POST /session] to [POST http://127.0.0.1:56118/session] with body: {"capabilities":{"alwaysMatch":{"goog:chromeOptions":{"androidPackage":"com.romypackage.rl.debug","androidUseRunningApp":true,"androidProcess":"com.romypackage.rl.debug","androidDeviceSerial":"37281FDJH00B62"},"goog:loggingPrefs":{"browser":"ALL"}}}}
[Chromedriver@d388] Webview version: 'Chrome/127.0.6533.103'
***********************************************
THIS IS THE POINT THE NATIVE ELEMENT IS TAPPED
***********************************************
[Chromedriver@d388] Got response with status 200: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"127.0.6533.103","chrome":{"chromedriverVersion":"127.0.6533.99 (f31af5097d90ef5ae5bd7b8700199bc6189ba34d-refs/branch-heads/6533@{#1910})"},"fedcm:accounts":true,"goog:chromeOptions":{"debuggerAddress":"localhost:56128"},"pageLoadStrategy":"normal","platformName":"android","proxy":{},"setWindowRect":false,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:credBlob":false,"webauthn:extension:largeBlob":false,"webauthn:extension:minPinLength":false,"webauthn:extension:prf":false,"webauthn:virtualAuthenticators":false},"sessionId":"a6ea5d4e02989d6162e1f3eafa82a08f"}}
[Chromedriver@d388] Determined the downstream protocol as 'W3C'
[Chromedriver@d388] Changed state to 'online'
[AndroidUiautomator2Driver@7618 (f4b16c01)] Responding to client with driver.setContext() result: null
[HTTP] <-- POST /session/f4b16c01-dd8c-4f1c-ad22-f3848e789535/context 200 10374 ms - 14
[HTTP]