An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2

Appium version: 1.22.2
Java-client: 7.6.0
TestNG: 7.4.0

When executing Tests in real device from TestNG.xml, always second test failed and reason for failure which I found in appium server is listed below.

Appium Server Logs:
Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: ‘POST /element’ cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
[W3C (f49c1652)] at UIA2Proxy.command (C:\Users\kiku01\AppData\Local\Programs\Appium Server GUI\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\jsonwp-proxy\proxy.js:274:13)
[W3C (f49c1652)] at processTicksAndRejections (internal/process/task_queues.js:85:5)
[HTTP] <-- POST /wd/hub/session/f49c1652-a652-41f7-9ab7-5b5cec0f2319/element 500

Logcat Logs
--------- beginning of crash
01-20 22:55:43.233 13074 13115 E AndroidRuntime: FATAL EXCEPTION: Instr: androidx.test.runner.AndroidJUnitRunner
01-20 22:55:43.233 13074 13115 E AndroidRuntime: Process: io.appium.uiautomator2.server, PID: 13074
01-20 22:55:43.233 13074 13115 E AndroidRuntime: java.lang.IllegalStateException: UiAutomation not connected, UiAutomation@6e1b0a[id=-1, flags=0]
01-20 22:55:43.233 13074 13115 E AndroidRuntime: at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1239)
01-20 22:55:43.233 13074 13115 E AndroidRuntime: at android.app.UiAutomation.disconnect(UiAutomation.java:296)
01-20 22:55:43.233 13074 13115 E AndroidRuntime: at android.app.Instrumentation.finish(Instrumentation.java:249)
01-20 22:55:43.233 13074 13115 E AndroidRuntime: at androidx.test.runner.MonitoringInstrumentation.finish(MonitoringInstrumentation.java:367)
01-20 22:55:43.233 13074 13115 E AndroidRuntime: at androidx.test.runner.AndroidJUnitRunner.finish(AndroidJUnitRunner.java:415)
01-20 22:55:43.233 13074 13115 E AndroidRuntime: at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:404)
01-20 22:55:43.233 13074 13115 E AndroidRuntime: at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2218)
01-20 22:56:20.159 20464 20521 E AndroidRuntime: FATAL EXCEPTION: Instr: androidx.test.runner.AndroidJUnitRunner

Did anyone face similar issues?
Help me with solution if you have any.

I have executed in Samsung and One Plus6, No luck am facing the same issues in both devices.

1 Like

I am also facing the same issue…please let me know if you found any solution for the same.

Here the issue is without quiting the driver(driver.quit()) second test started to execute in the same session. When the second test get Android or appium driver object then there are two sessions exits and appium server unable to handle this case(since there are two sessions).

I handled in code to quit Android or Appium driver properly then start executing second test.

2 Likes

Can you please share more details on what you did to quit Android or Appium driver