Selenium posting command to already killed driver session of appium


#1

My selenium hub is posting it’s command to an already killed session.

I have set the driver instantiation at the class level using @beforeclass and killing it @afterclass.

I have 2 testcases. For example:

class A - contains login page tests class B - contains landing page tests.

After executing tests in class A the created is being removed:

Removing session b384cee7-56a5-45db-83ca-910b115cbe37 from our master session list

The tests now instantiate a new android driver (with session d29a785f-23fd-4c81-a623-8b96ca2b384d and begins executing tests in class B.

But selenium hub posts the command to b384cee7-56a5-45db-83ca-910b115cbe37.

I am just able make sense out of this. Could somebody help me as to why this may be happening.

2019-01-16 15:03:34:190 - [HTTP] <-- GET /wd/hub/session/d29a785f-23fd-4c81-a623-8b96ca2b384d/screenshot 200 394 ms - 272952
2019-01-16 15:03:34:190 - [HTTP]
2019-01-16 15:03:34:238 - [HTTP] --> POST /wd/hub/session/d29a785f-23fd-4c81-a623-8b96ca2b384d/timeouts
2019-01-16 15:03:34:238 - [HTTP] {“implicit”:0}
2019-01-16 15:03:34:238 - [debug] [W3C (d29a785f)] Calling AppiumDriver.timeouts() with args: [null,null,null,null,0,“d29a785f-23fd-4c81-a623-8b96ca2b384d”]
2019-01-16 15:03:34:240 - [debug] [BaseDriver] W3C timeout argument: {“implicit”:0}}
2019-01-16 15:03:34:240 - [debug] [BaseDriver] Set implicit wait to 0ms
2019-01-16 15:03:34:240 - [debug] [W3C (d29a785f)] Responding to client with driver.timeouts() result: null
2019-01-16 15:03:34:241 - [HTTP] <-- POST /wd/hub/session/d29a785f-23fd-4c81-a623-8b96ca2b384d/timeouts 200 3 ms - 14
2019-01-16 15:03:34:241 - [HTTP]
2019-01-16 15:03:34:248 - [HTTP] --> POST /wd/hub/session/b384cee7-56a5-45db-83ca-910b115cbe37/elements
2019-01-16 15:03:34:249 - [HTTP] {“using”:“xpath”,“value”:"//android.widget.FrameLayout[@content-desc=“list-template0-group3-hpanel0”]/android.widget.FrameLayout"}
2019-01-16 15:03:34:275 - [debug] [W3C (b384cee7)] Encountered internal error running command: NoSuchDriverError: A session is either terminated or not started
2019-01-16 15:03:34:275 - [debug] [W3C (b384cee7)] at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:298:15)
2019-01-16 15:03:34:276 - [debug] [W3C (b384cee7)] at app.(anonymous function) (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:492:15)
2019-01-16 15:03:34:276 - [debug] [W3C (b384cee7)] at Layer.handle [as handle_request] (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
2019-01-16 15:03:34:276 - [debug] [W3C (b384cee7)] at next (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/route.js:137:13)
2019-01-16 15:03:34:276 - [debug] [W3C (b384cee7)] at Route.dispatch (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/route.js:112:3)
2019-01-16 15:03:34:276 - [debug] [W3C (b384cee7)] at Layer.handle [as handle_request] (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
2019-01-16 15:03:34:276 - [debug] [W3C (b384cee7)] at /usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:281:22
2019-01-16 15:03:34:277 - [debug] [W3C (b384cee7)] at param (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:354:14)
2019-01-16 15:03:34:277 - [debug] [W3C (b384cee7)] at param (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:365:14)
2019-01-16 15:03:34:277 - [debug] [W3C (b384cee7)] at Function.process_params (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:410:3)
2019-01-16 15:03:34:277 - [debug] [W3C (b384cee7)] at next (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:275:10)
2019-01-16 15:03:34:277 - [debug] [W3C (b384cee7)] at logger (/usr/local/lib/node_modules/appium/node_modules/morgan/index.js:144:5)
2019-01-16 15:03:34:278 - [debug] [W3C (b384cee7)] at Layer.handle [as handle_request] (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
2019-01-16 15:03:34:278 - [debug] [W3C (b384cee7)] at trim_prefix (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:317:13)
2019-01-16 15:03:34:278 - [debug] [W3C (b384cee7)] at /usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:284:7
2019-01-16 15:03:34:278 - [debug] [W3C (b384cee7)] at Function.process_params (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:335:12)
2019-01-16 15:03:34:278 - [debug] [W3C (b384cee7)] at next (/usr/local/lib/node_modules/appium/node_modules/express/lib/router/index.js:275:10)
2019-01-16 15:03:34:278 - [debug] [W3C (b384cee7)] at /usr/local/lib/node_modules/appium/node_modules/body-parser/lib/read.js:130:5
2019-01-16 15:03:34:278 - [debug] [W3C (b384cee7)] at invokeCallback (/usr/local/lib/node_modules/appium/node_modules/raw-body/index.js:224:16)
2019-01-16 15:03:34:279 - [debug] [W3C (b384cee7)] at done (/usr/local/lib/node_modules/appium/node_modules/raw-body/index.js:213:7)
2019-01-16 15:03:34:279 - [debug] [W3C (b384cee7)] at IncomingMessage.onEnd (/usr/local/lib/node_modules/appium/node_modules/raw-body/index.js:273:7)
2019-01-16 15:03:34:279 - [debug] [W3C (b384cee7)] at emitNone (events.js:106:13)
2019-01-16 15:03:34:279 - [debug] [W3C (b384cee7)] at IncomingMessage.emit (events.js:208:7)
2019-01-16 15:03:34:279 - [debug] [W3C (b384cee7)] at endReadableNT (_stream_readable.js:1064:12)
2019-01-16 15:03:34:279 - [debug] [W3C (b384cee7)] at _combinedTickCallback (internal/process/next_tick.js:139:11)
2019-01-16 15:03:34:280 - [debug] [W3C (b384cee7)] at process._tickCallback (internal/process/next_tick.js:181:9)
2019-01-16 15:03:34:282 - [HTTP] <-- POST /wd/hub/session/b384cee7-56a5-45db-83ca-910b115cbe37/elements 404 32 ms - 2658
2019-01-16 15:03:34:282 - [HTTP]
2019-01-16 15:03:35:301 - [HTTP] --> GET /wd/hub/session/d29a785f-23fd-4c81-a623-8b96ca2b384d/window/rect

Expected Behaviour:

Selenium hub should not have posted to the deleted session b384cee7-56a5-45db-83ca-910b115cbe37 as this session was terminated after executing tests in classA.

Version

appium - 1.10.1
selenium hub - 3.14.0
TestNG - 6.14.3