Issue with Context Switching in Appium

I’ve encountered an issue while trying to switch contexts in my Appium automation script. The scenario involves switching to the ‘’ context, but I’m encountering errors related to port forwarding.

Summary of the Problem:

  1. Context Switch Attempt: The script attempts to switch to the ‘’ context.
  2. Webview Identification: Two webview contexts are identified: “” and “”.
  3. Port Forwarding: The AndroidDriver initiates port forwarding for the identified webview contexts.
  4. Chromedriver Connection: Chromedriver initialization proceeds with the provided capabilities.
  5. Chromedriver Version: Chromedriver version ‘123.0.6312.105’ is utilized.
  6. Chromedriver Session Creation: A new Chromedriver session is started based on the provided capabilities.
  7. Error Occurrence: The error arises during the port forwarding process for the ‘’ context, leading to a 404 status code.

Any insights or suggestions on resolving this issue would be greatly appreciated. Thank you in advance for your help!

Appium Server log
[W3C (2d06681e)] Responding to client with driver.getCurrentContext() result: “NATIVE_APP”
[HTTP] ← GET /wd/hub/session/2d06681e-a78b-4015-b2dd-77da189eaf39/context 200 1 ms - 22
[HTTP] → POST /wd/hub/session/2d06681e-a78b-4015-b2dd-77da189eaf39/context
[HTTP] {“name”:“”}
[W3C (2d06681e)] Calling AppiumDriver.setContext() with args: [“”,“2d06681e-a78b-4015-b2dd-77da189eaf39”]
[AndroidDriver] Getting a list of available webviews
[ADB] Running ‘/Users/kuma/Library/Android/sdk/platform-tools/adb -P 5037 -s {androidDeviceSerial} shell cat /proc/net/unix’
[AndroidDriver] Parsed 2 active devtools sockets: [“@webview_devtools_remote_19065”,“”]
[AndroidDriver] Collecting CDP data of 2 webviews
[AndroidDriver] Forwarding remote port webview_devtools_remote_19065 to a local port in range 10900…11000
[AndroidDriver] You could use the ‘webviewDevtoolsPort’ capability to customize the starting port number
[AndroidDriver] Forwarding remote port to a local port in range 10900…11000
[AndroidDriver] You could use the ‘webviewDevtoolsPort’ capability to customize the starting port number
[ADB] Running ‘/Users/kuma/Library/Android/sdk/platform-tools/adb -P 5037 -s {androidDeviceSerial} forward tcp:10900 localabstract:webview_devtools_remote_19065’
[ADB] Removing forwarded port socket connection: 10900
[ADB] Running ‘/Users/kuma/Library/Android/sdk/platform-tools/adb -P 5037 -s {androidDeviceSerial} forward --remove tcp:10900’
[ADB] Running ‘/Users/kuma/Library/Android/sdk/platform-tools/adb -P 5037 -s {androidDeviceSerial} forward tcp:10901’
[AndroidDriver] Error: Request failed with status code 404
[AndroidDriver] at createError (/Applications/Appium Server
[AndroidDriver] at settle (/Applications/Appium Server
[AndroidDriver] at IncomingMessage.handleStreamEnd (/Applications/Appium Server
[AndroidDriver] at IncomingMessage.emit (events.js:322:22)
[AndroidDriver] at endReadableNT (_stream_readable.js:1187:12)
[AndroidDriver] at processTicksAndRejections (internal/process/task_queues.js:84:21)
[ADB] Removing forwarded port socket connection: 10901
[ADB] Running ‘/Users/kuma/Library/Android/sdk/platform-tools/adb -P 5037 -s {androidDeviceSerial} forward --remove tcp:10901’
[AndroidDriver] CDP data collection completed
[AndroidDriver] WEBVIEW_19065 mapped to pid 19065
[AndroidDriver] Getting process name for webview ‘WEBVIEW_19065’
[ADB] Running ‘/Users/kuma/Library/Android/sdk/platform-tools/adb -P 5037 -s {androidDeviceSerial} shell ps -A’
[AndroidDriver] Got process name: ‘’
[AndroidDriver] Found 2 webviews: [“”,“”]
[AndroidDriver] Available contexts: [“NATIVE_APP”,“”,“”]
[AndroidDriver] Connecting to chrome-backed webview context ‘’
[AndroidDriver] A port was not given, using random free port: 8000
[AndroidDriver] Passing web view details to the Chromedriver constructor: {
[AndroidDriver] “info”: {
[AndroidDriver] “Android-Package”: “”,
[AndroidDriver] “Browser”: “Chrome/123.0.6312.99”,
[AndroidDriver] “Protocol-Version”: “1.3”,
[AndroidDriver] “User-Agent”: “Mozilla/5.0 (Linux; Android 13; SM-A325N Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/123.0.6312.99 Mobile Safari/537.36”,
[AndroidDriver] “V8-Version”: “”,
[AndroidDriver] “WebKit-Version”: “537.36 (@03fbddf498224f2bcca36d06c44df0d5f625067e)”,
[AndroidDriver] “webSocketDebuggerUrl”: “ws://”
[AndroidDriver] },
[AndroidDriver] “process”: {
[AndroidDriver] “name”: “”,
[AndroidDriver] “id”: “19065”
[AndroidDriver] }
[AndroidDriver] }
[AndroidDriver] Precalculated Chromedriver capabilities: {
[AndroidDriver] “androidPackage”: “”,
[AndroidDriver] “androidUseRunningApp”: true,
[AndroidDriver] “androidProcess”: “”,
[AndroidDriver] “androidDeviceSerial”: “{androidDeviceSerial}”
[AndroidDriver] }
[AndroidDriver] Before starting chromedriver, androidPackage is ‘’
[Chromedriver] Changed state to ‘starting’
[Chromedriver] Set chromedriver binary as: /Users/kuma/PycharmProjects/qe_appium/qeproject/common/chromedriver/chromedriver123_64
[Chromedriver] Killing any old chromedrivers, running: pkill -15 -f “/Users/kuma/PycharmProjects/qe_appium/qeproject/common/chromedriver/chromedriver123_64.*–port=8000”
[Chromedriver] No old chromedrivers seem to exist
[Chromedriver] Cleaning this device’s adb forwarded port socket connections: {androidDeviceSerial}
[ADB] List forwarding ports
[ADB] Running ‘/Users/kuma/Library/Android/sdk/platform-tools/adb -P 5037 -s {androidDeviceSerial} forward --list’
[ADB] Removing forwarded port socket connection: 62807
[ADB] Running ‘/Users/kuma/Library/Android/sdk/platform-tools/adb -P 5037 -s {androidDeviceSerial} forward --remove tcp:62807’
[Chromedriver] Spawning chromedriver with: /Users/kuma/PycharmProjects/qe_appium/qeproject/common/chromedriver/chromedriver123_64 --url-base=wd/hub --port=8000 --adb-port=5037 --verbose
[Chromedriver] Chromedriver version: ‘123.0.6312.105’
[Chromedriver] Chromedriver v. 123.0.6312.105 supports W3C protocol, but MJSONWP one has been explicitly requested
[WD Proxy] Matched ‘/status’ to command name ‘getStatus’
[WD Proxy] Proxying [GET /status] to [GET] with no body
[WD Proxy] connect ECONNREFUSED
[WD Proxy] Matched ‘/status’ to command name ‘getStatus’
[WD Proxy] Proxying [GET /status] to [GET] with no body
[WD Proxy] Got response with status 200: {“value”:{“build”:{“version”:“123.0.6312.105 (399174dbe6eff0f59de9a6096129c0c827002b3a-refs/branch-heads/6312@{#761})”},“message”:“ChromeDriver ready for new sessions.”,“os”:{“arch”:“arm64”,“name”:“Mac OS X”,“version”:“13.4.0”},“ready”:true}}
[Chromedriver] Starting MJSONWP Chromedriver session with capabilities: {
[Chromedriver] “desiredCapabilities”: {
[Chromedriver] “chromeOptions”: {
[Chromedriver] “androidPackage”: “”,
[Chromedriver] “androidUseRunningApp”: true,
[Chromedriver] “androidProcess”: “”,
[Chromedriver] “androidDeviceSerial”: “{androidDeviceSerial}”,
[Chromedriver] “w3c”: false
[Chromedriver] },
[Chromedriver] “loggingPrefs”: {
[Chromedriver] “browser”: “ALL”
[Chromedriver] }
[Chromedriver] }
[Chromedriver] }
[WD Proxy] Matched ‘/session’ to command name ‘createSession’
[WD Proxy] Proxying [POST /session] to [POST] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“”,“androidUseRunningApp”:true,“androidProcess”:“”,“androidDeviceSerial”:“androidDeviceSerial”,“w3c”:false},“loggingPrefs”:{“browser”:“ALL”}}}
[Chromedriver] Webview version: ‘Chrome/123.0.6312.99’

I found the cause. It seems that the Webview version is not working because it is the latest version. I lowered the Webview version and it worked normally.

I had to set chrome to be the default browser on the device, what device is it that has that browser by default? I am curious to know which browser it is and why.