Does appium create multiple sessions?

Below is a snippet of some logs from my using of appium.
I’m using the dotnet client with appium 2.0.1.
It looks like appium is asking for an element via one session and getting a response from a different session ??
I’m not sure what’s happening here, if someone could explain it would be much appreciated.

19.10.2023 15:44:05 [HTTP] [HTTP] → POST /session/b296d2ce-26aa-46d4-ab4d-4f1b0cb80d97/element
19.10.2023 15:44:05 [HTTP] [HTTP] {“using”:“id”,“value”:“login_button”}
19.10.2023 15:44:05 [debug] [AndroidUiautomator2Driver@2626 (b296d2ce)] [AndroidUiautomator2Driver@2626 (b296d2ce)] Calling AppiumDriver.findElement() with args: [“id”,“login_button”,“b296d2ce-26aa-46d4-ab4d-4f1b0cb80d97”]
19.10.2023 15:44:05 [debug] [AndroidUiautomator2Driver@2626 (b296d2ce)] [AndroidUiautomator2Driver@2626 (b296d2ce)] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
19.10.2023 15:44:05 [debug] [AndroidUiautomator2Driver@2626 (b296d2ce)] [AndroidUiautomator2Driver@2626 (b296d2ce)] Waiting up to 1000 ms for condition
19.10.2023 15:44:05 [debug] [AndroidUiautomator2Driver@2626 (b296d2ce)] [AndroidUiautomator2Driver@2626 (b296d2ce)] Matched ‘/element’ to command name ‘findElement’
19.10.2023 15:44:05 [debug] [AndroidUiautomator2Driver@2626 (b296d2ce)] [AndroidUiautomator2Driver@2626 (b296d2ce)] Proxying [POST /element] to [POST] with body: {“strategy”:“id”,“selector”:“login_button”,“context”:“”,“multiple”:false}
19.10.2023 15:44:05 [debug] [AndroidUiautomator2Driver@2626 (b296d2ce)] [AndroidUiautomator2Driver@2626 (b296d2ce)] Got response with status 200: {“sessionId”:“ee063e29-c1eb-46f8-a692-e221e01e4252”,“value”:{“ELEMENT”:“00000000-0001-f9c8-ffff-ffff00000021”,“element-6066-11e4-a52e-4f735466cecf”:“00000000-0001-f9c8-ffff-ffff00000021”}}
19.10.2023 15:44:05 [debug] [AndroidUiautomator2Driver@2626 (b296d2ce)] [AndroidUiautomator2Driver@2626 (b296d2ce)] Responding to client with driver.findElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“00000000-0001-f9c8-ffff-ffff00000021”,“ELEMENT”:“00000000-0001-f9c8-ffff-ffff00000021”}

From time to time I also get some of these which I don’t know what they mean:

19.10.2023 15:44:33 [AndroidUiautomator2Driver@2626 (b296d2ce)] [AndroidUiautomator2Driver@2626 (b296d2ce)] Replacing sessionId ee063e29-c1eb-46f8-a692-e221e01e4252 with b296d2ce-26aa-46d4-ab4d-4f1b0cb80d97

You are right, this log line itself is confusing, it is only clear for people who maintain this stuff.
Basically, what happens there are two sessions running at the same time. One session (the first uuid) is the upstream session that is visible to your client and which is receiving commands from it. This session is handled by the Appium’s node.js server. The second one is “hidden” and is running on the device itself backed up by the specially instrumented runner written in java. The second uuid is exactly the id of the internal session. The second downstream session is run by the server component deployed to the device under test receives refined commands from the upstream session. Also, responses from it are proxied to the upstream session.

1 Like