appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.22k stars 758 forks source link

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: Could not proxy command to the remote server. Original error: timeout of 240000ms exceeded #2075

Open dipakkumar1225 opened 12 months ago

dipakkumar1225 commented 12 months ago

Description

Now able to switch to WebView.

Environment

Code To Reproduce Issue

protected void switchToWebViewContext() {
    String strWebContextName = ((AndroidDriver)getAppiumDriver()).getContextHandles().stream().filter(ctx -> ctx.contains("WEBVIEW_")).findAny().orElse(null);
    System.out.println("strWebContextName " + strWebContextName);
    if (Objects.nonNull(strWebContextName)) {
        ((AndroidDriver) getAppiumDriver()).context(strWebContextName);
        System.out.println("Switched to Web view ");
    }
}

here I am able to get webview context name strWebContextName WEBVIEW_com.xxxxx.xxxxxxx

Exception Stacktraces

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: Could not proxy command to the remote server. Original error: timeout of 240000ms exceeded
Build info: version: '4.15.0', revision: '1d14b5521b'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [bddfd85a-6e5e-46c2-842e-1b8371fc128a, switchToContext {name=WEBVIEW_com.xxxx.xxxxuat}]
Capabilities {appium:app: D:\MobiWebAutoFramework\mob..., appium:appActivity: com.xxxx.xxxx.activity..., appium:appPackage: com.xxxx.xxxxuat, appium:autoGrantPermissions: true, appium:autoLaunch: false, appium:automationName: UIAutomator2, appium:chromedriverExecutable: D:\chromedriver-win32\chrom..., appium:chromedriverPort: 10002, appium:clearDeviceLogsOnStart: true, appium:clearSystemFiles: true, appium:databaseEnabled: false, appium:desired: {app: D:\MobiWebAutoFramework\mob..., appActivity: com.xxxx.xxxx.activity..., appPackage: com.xxxx.xxxxuat, autoGrantPermissions: true, autoLaunch: false, automationName: UIAutomator2, chromedriverExecutable: D:\chromedriver-win32\chrom..., chromedriverPort: 10002, clearDeviceLogsOnStart: true, clearSystemFiles: true, ensureWebviewsHavePages: true, fullReset: false, ignoreHiddenApiPolicyError: true, mjpegServerPort: 62920, nativeWebScreenshot: true, newCommandTimeout: 240, noReset: true, platformName: ANDROID, platformVersion: 13, shouldTerminateApp: true, showChromedriverLog: true, systemPort: 10001, udid: ZD222CJSXB, webviewDevtoolsPort: 10901}, appium:deviceApiLevel: 33, appium:deviceManufacturer: motorola, appium:deviceModel: motorola edge 30, appium:deviceName: ZD222CJSXB, appium:deviceScreenDensity: 400, appium:deviceScreenSize: 1080x2400, appium:deviceUDID: ZD222CJSXB, appium:ensureWebviewsHavePages: true, appium:fullReset: false, appium:ignoreHiddenApiPolicyError: true, appium:javascriptEnabled: true, appium:locationContextEnabled: false, appium:mjpegServerPort: 62920, appium:nativeWebScreenshot: true, appium:networkConnectionEnabled: true, appium:newCommandTimeout: 240, appium:noReset: true, appium:pixelRatio: 2.5, appium:platformVersion: 13, appium:shouldTerminateApp: true, appium:showChromedriverLog: true, appium:statBarHeight: 105, appium:systemPort: 10001, appium:takesScreenshot: true, appium:udid: ZD222CJSXB, appium:viewportRect: {height: 2130, left: 0, top: 105, width: 1080}, appium:warnings: {}, appium:webStorageEnabled: false, appium:webviewDevtoolsPort: 10901, platformName: ANDROID}
Session ID: bddfd85a-6e5e-46c2-842e-1b8371fc128a

Link To Appium Logs

https://gist.github.com/dipakkumar1225/e83e2a3c0b2c63a10db070fb489141ff#file-webcontext

ashwithpoojary98 commented 11 months ago

@dipakkumar1225 Does an app designed as a hybrid app, Try switching context directly.

dipakkumar1225 commented 11 months ago

@dipakkumar1225 Does an app designed as a hybrid app, Try switching context directly.

@ashwithpoojary98

In application, some parts of the modules are in Webview.

Please explain "Try switching context directly"

shinobi01 commented 7 months ago

facing the same issue, I'm able to see context list by using ((SupportsContextSwitching) world.driver).getContextHandles() but unable to switch to it via: ((SupportsContextSwitching) world.driver).context("WEBVIEW_xxxxx") Update: I found it should be related to Android System WebView version. I'm able to switch context via 122.0.6261.64, but failed with version 122.0.6261.119 Uninstall Android System WebView updates from Settings works for me.

ihorbovkit commented 7 months ago

Do we have any updates here? Im having the same with - Appium v2.5.2 uiautomator2@3.0.7 Chrome/123.0.6312.99 Appium_logs.txt