0

Unable to switch to web view context in Appium v2.0.0-beta.46 and v2.0.0-beta.47

Same code working fine in Appium v1.22.3

Error:

Got response with status 500: {"value":{"error":"disconnected","message":"disconnected: unable to connect to renderer\n (failed to check if window was closed: disconnected: unable to connect to renderer

Code:

//Driver details
capability.setCapability("device", aDevice);
capability.setCapability("newCommandTimeout", 100000);
capability.setCapability("platformName", platform);
capability.setCapability("udid", aUdid);
capability.setCapability("appPackage", appPkg); 
capability.setCapability("appActivity", appAct);
capability.setCapability("automationName", "UiAutomator2");
capability.setCapability("setWebContentsDebuggingEnabled", true);

AppiumDriver driver = new AndroidDriver(new URL(serverUrl), capability);

Set<String> contexts = ((SupportsContextSwitching) driver()).getContextHandles();
        System.out.println("CONTEXT="+contexts);  //prints CONTEXT=[NATIVE_APP, WEBVIEW_chrome]
         for (String context : contexts) {
             if (context.contains("WEBVIEW")) {
                 ((SupportsContextSwitching) driver()).context(context);
                 break;
             }
         }

Exceptions:

io.appium.java_client.NoSuchContextException: An unknown server-side error occurred while processing the command. Original error: An unknown server-side error occurred while processing the command. Original error: disconnected: unable to connect to renderer (failed to check if window was closed: disconnected: unable to connect to renderer) (Session info: chrome=108.0.5359.79) Build info: version: '4.6.0', revision: '79f1c02ae20' System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '12.6', java.version: '11.0.10' Driver info: io.appium.java_client.android.AndroidDriver Command: [0b2b612b-473a-456b-a281-842d6e138aa9, switchToContext {name=WEBVIEW_chrome}] Capabilities {appium:appActivity: com.tech.service..., appium:appPackage: com.tech.service..., appium:applicationCacheEnabled: false, appium:automationName: UIAutomator2, appium:databaseEnabled: false, appium:desired: {appActivity: com.tech.service..., appPackage: com.tech.service..., applicationCacheEnabled: false, automationName: UIAutomator2, device: Pixel 6, newCommandTimeout: 100000, platformName: android, setWebContentsDebuggingEnabled: true, udid: RXCABCD}, appium:device: Pixel 6, appium:deviceApiLevel: 31, appium:deviceManufacturer: samsung, appium:deviceModel: SM-G770F, appium:deviceName: RXCABCD, appium:deviceScreenDensity: 420, appium:deviceScreenSize: 1080x2400, appium:deviceUDID: RXCABCD, appium:javascriptEnabled: true, appium:locationContextEnabled: false, appium:networkConnectionEnabled: true, appium:newCommandTimeout: 100000, appium:pixelRatio: 2.625, appium:platformVersion: 12, appium:setWebContentsDebuggingEnabled: true, appium:statBarHeight: 90, appium:takesScreenshot: true, appium:udid: RXCABCD, appium:viewportRect: {height: 2091, left: 0, top: 90, width: 1080}, appium:warnings: {}, appium:webStorageEnabled: false, platformName: ANDROID} Session ID: 0b2b612b-473a-456b-a281-842d6e138aa9

Appium Logs:

[debug] [AndroidDriver] Getting a list of available webviews [debug] [ADB] Running '/Users/tech/Library/Android/sdk/platform-tools/adb -P 5037 -s RXCABCD shell cat /proc/net/unix' [debug] [AndroidDriver] Parsed 1 active devtools socket: ["@chrome_devtools_remote"] [debug] [AndroidDriver] Collecting CDP data of 1 webview [debug] [AndroidDriver] Forwarding remote port chrome_devtools_remote to a local port in range 10900..11000 [debug] [AndroidDriver] You could use the 'webviewDevtoolsPort' capability to customize the starting port number [debug] [ADB] Running '/Users/tech/Library/Android/sdk/platform-tools/adb -P 5037 -s RXCABCD forward tcp:10900 localabstract:chrome_devtools_remote' [debug] [ADB] Removing forwarded port socket connection: 10900 [debug] [ADB] Running '/Users/tech/Library/Android/sdk/platform-tools/adb -P 5037 -s RXCABCD forward --remove tcp:10900' [debug] [AndroidDriver] CDP data collection completed [debug] [AndroidDriver] Found 1 webview: ["WEBVIEW_chrome"] [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] Available contexts: ["NATIVE_APP","WEBVIEW_chrome"] [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] Connecting to chrome-backed webview context 'WEBVIEW_chrome' [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] Identified chromeAndroidPackage as 'com.android.chrome' for context 'WEBVIEW_chrome' by CDP [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] A port was not given, using random free port: 8000 [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] Passing web view details to the Chromedriver constructor: { [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] "info": { [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] "Android-Package": "com.android.chrome", [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] "Browser": "Chrome/108.0.5359.79", [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] "Protocol-Version": "1.3", [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] "User-Agent": "Mozilla/5.0 (Linux; Android 12; SM-G770F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Mobile Safari/537.36", [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] "V8-Version": "10.8.168.21", [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] "WebKit-Version": "537.36 (@5194e1e1073e30a8fc93c72c2aee4bc572f5b07a)", [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] "webSocketDebuggerUrl": "ws://127.0.0.1:10900/devtools/browser" [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] }, [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] "process": { [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] "name": "chrome", [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] "id": null [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] } [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] } [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] Automated Chromedriver download is disabled. Use 'chromedriver_autodownload' server feature to enable it [debug] [AndroidDriver] Precalculated Chromedriver capabilities: { [debug] [AndroidDriver] "androidPackage": "com.android.chrome", [debug] [AndroidDriver] "androidUseRunningApp": true, [debug] [AndroidDriver] "androidDeviceSerial": "RXCABCD" [debug] [AndroidDriver] } [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] Before starting chromedriver, androidPackage is 'com.android.chrome' [debug] [Chromedriver@4fe7] Changed state to 'starting' [debug] [Chromedriver@4fe7] Using the static Chromedriver->Chrome mapping [debug] [Chromedriver@4fe7] The most recent known Chrome version: 108.0.5359 [debug] [Chromedriver@4fe7] Found 1 executable in '/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac' [debug] [Chromedriver@4fe7] The following Chromedriver executables were found: [debug] [Chromedriver@4fe7] '/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v108.0.5359.71' (version '108.0.5359.71', minimum Chrome version '108.0.5359') [debug] [Chromedriver@4fe7] Browser version in the supplied details: Chrome/108.0.5359.79 [debug] [Chromedriver@4fe7] Found Chrome bundle 'undefined' version '108.0.5359' [debug] [Chromedriver@4fe7] Found 1 executable capable of automating Chrome '108.0.5359'. [debug] [Chromedriver@4fe7] Choosing the most recent, '/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v108.0.5359.71'. [debug] [Chromedriver@4fe7] If a specific version is required, specify it with the chromedriverExecutabledesired capability. [Chromedriver@4fe7] Set chromedriver binary as: /Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v108.0.5359.71 [debug] [Chromedriver@4fe7] Killing any old chromedrivers, running: pkill -15 -f "/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v108.0.5359.71.*--port=8000" [Chromedriver@4fe7] No old chromedrivers seem to exist [debug] [Chromedriver@4fe7] Cleaning this device's adb forwarded port socket connections: RXCABCD [debug] [ADB] List forwarding ports [debug] [ADB] Running '/Users/tech/Library/Android/sdk/platform-tools/adb -P 5037 -s RXCABCD forward --list' [Chromedriver@4fe7] Spawning chromedriver with: /Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v108.0.5359.71 --port=8000 --adb-port=5037 --verbose [debug] [Chromedriver@4fe7] Chromedriver version: '108.0.5359.71' [debug] [Chromedriver@4fe7] Matched '/status' to command name 'getStatus' [debug] [Chromedriver@4fe7] Proxying [GET /status] to [GET http://127.0.0.1:8000/status] with no body [debug] [Chromedriver@4fe7] Got response with status 200: {"value":{"build":{"version":"108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016})"},"message":"ChromeDriver ready for new sessions.","os":{"arch":"x86_64","name":"Mac OS X","version":"12.6.0"},"ready":true}} [Chromedriver@4fe7] Starting W3C Chromedriver session with capabilities: { [Chromedriver@4fe7] "capabilities": { [Chromedriver@4fe7] "alwaysMatch": { [Chromedriver@4fe7] "goog:chromeOptions": { [Chromedriver@4fe7] "androidPackage": "com.android.chrome", [Chromedriver@4fe7] "androidUseRunningApp": true, [Chromedriver@4fe7] "androidDeviceSerial": "RXCABCD" [Chromedriver@4fe7] }, [Chromedriver@4fe7] "goog:loggingPrefs": { [Chromedriver@4fe7] "browser": "ALL" [Chromedriver@4fe7] } [Chromedriver@4fe7] } [Chromedriver@4fe7] } [Chromedriver@4fe7] } [debug] [Chromedriver@4fe7] Matched '/session' to command name 'createSession' [debug] [Chromedriver@4fe7] Proxying [POST /session] to [POST http://127.0.0.1:8000/session] with body: {"capabilities":{"alwaysMatch":{"goog:chromeOptions":{"androidPackage":"com.android.chrome","androidUseRunningApp":true,"androidDeviceSerial":"RXCABCD"},"goog:loggingPrefs":{"browser":"ALL"}}}} [debug] [Chromedriver@4fe7] Webview version: 'Chrome/108.0.5359.79' [Chromedriver@4fe7] Got response with status 500: {"value":{"error":"disconnected","message":"disconnected: unable to connect to renderer\n (failed to check if window was closed: disconnected: unable to connect to renderer)\n (Session info: chrome=108.0.5359.79)","stacktrace":"0 chromedriver_mac64_v108.0.5359.71 0x0000000101a45f38 chromedriver_mac64_v108.0.5359.71 + 4910904\n1 chromedriver_mac64_v108.0.5359.71 0x00000001019c5a03 chromedriver_mac64_v108.0.5359.71 + 4385283\n2 chromedriver_mac64_v108.0.5359.71 0x000000010160a747 chromedriver_mac64_v108.0.5359.71 + 472903\n3 chromedriver_mac64_v108.0.5359.71 0x00000001015ef7ea chromedriver_mac64_v108.0.5359.71 + 362474\n4 chromedriver_mac64_v108.0.5359.71 0x00000001015dee19 chromedriver_mac64_v108.0.5359.71 + 294425\n5 chromedriver_mac64_v108.0.5359.71 0x00000001015de9f5 chromedriver_mac64_v108.0.5359.71 + 293365\n6 chromedriver_mac64_v108.0.5359.71 0x000000010167e578 chromedriver_mac64_v108.0.5359.71 + 947576\n7 chromedriver_mac64_v108.0.5359.71 0x000000010167dcbf chromedri... [debug] [W3C] Matched W3C error code 'disconnected' to UnknownError [debug] [Chromedriver@4fe7] UnknownError: An unknown server-side error occurred while processing the command. Original error: disconnected: unable to connect to renderer [debug] [Chromedriver@4fe7] (failed to check if window was closed: disconnected: unable to connect to renderer) [debug] [Chromedriver@4fe7] (Session info: chrome=108.0.5359.79) [debug] [Chromedriver@4fe7] at errorFromW3CJsonCode (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/@appium/base-driver/lib/protocol/errors.js:928:23) [debug] [Chromedriver@4fe7] at ProxyRequestError.getActualError (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/@appium/base-driver/lib/protocol/errors.js:798:14) [debug] [Chromedriver@4fe7] at JWProxy.command (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:340:19) [debug] [Chromedriver@4fe7] at processTicksAndRejections (node:internal/process/task_queues:95:5) [debug] [Chromedriver@4fe7] at Chromedriver.startSession (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/lib/chromedriver.js:597:5) [debug] [Chromedriver@4fe7] at Chromedriver.start (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/lib/chromedriver.js:528:7) [debug] [Chromedriver@4fe7] at AndroidUiautomator2Driver.setupNewChromedriver (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context.js:471:3) [debug] [Chromedriver@4fe7] at AndroidUiautomator2Driver.startChromedriverProxy (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context.js:217:10) [debug] [Chromedriver@4fe7] at AndroidUiautomator2Driver.switchContext (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context.js:124:5) [debug] [Chromedriver@4fe7] at AndroidUiautomator2Driver.setContext (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context.js:51:3) [Chromedriver@4fe7] Chromedriver exited unexpectedly with code null, signal SIGTERM [debug] [Chromedriver@4fe7] Changed state to 'stopped' [Chromedriver@4fe7] An unknown server-side error occurred while processing the command. Original error: disconnected: unable to connect to renderer [Chromedriver@4fe7] (failed to check if window was closed: disconnected: unable to connect to renderer) [Chromedriver@4fe7] (Session info: chrome=108.0.5359.79) [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] Encountered internal error running command: Error: An unknown server-side error occurred while processing the command. Original error: disconnected: unable to connect to renderer [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] (failed to check if window was closed: disconnected: unable to connect to renderer) [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] (Session info: chrome=108.0.5359.79) [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] at Object.errorAndThrow (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/@appium/support/lib/logging.js:115:34) [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] at Chromedriver.start (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/lib/chromedriver.js:553:16) [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] at AndroidUiautomator2Driver.setupNewChromedriver (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context.js:471:3) [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] at AndroidUiautomator2Driver.startChromedriverProxy (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context.js:217:10) [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] at AndroidUiautomator2Driver.switchContext (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context.js:124:5) [debug] [AndroidUiautomator2Driver@20f3 (0b2b612b)] at AndroidUiautomator2Driver.setContext (/Users/tech/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/context.js:51:3) [HTTP] <-- POST /wd/hub/session/0b2b612b-473a-456b-a281-842d6e138aa9/context 500 720 ms - 1008

Karthik
  • 113
  • 2
  • 15

0 Answers0