Getting selenium.common.exceptions.WebDriverException: Message: A session is either terminated or not started when using winapp driver

0

I am running below pasted code to launch and perform click operation on windows calculator using python appium client and winapp driver:

    from appium import webdriver
    caps = {}
    caps["app"] = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"
    caps["platformName"] = "Windows"
    caps["deviceName"] = "M469727"
    caps["newCommandTimeout"] = 120
    session = webdriver.Remote(command_executor='http://127.0.0.1:4723/wd/hub', desired_capabilities=caps)

    session.find_element_by_name("Seven").click()

Error details:

C:\Users\admin\PycharmProjects\techdev\venv\Scripts\python.exe C:/Users/admin/PycharmProjects/techdev/basic_test.py
Traceback (most recent call last):
  File "C:/Users/admin/PycharmProjects/techdev/basic_test.py", line 12, in <module>
    session.find_element_by_name("Seven").click()
  File "C:\Users\admin\PycharmProjects\techdev\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 496, in find_element_by_name
    return self.find_element(by=By.NAME, value=name)
  File "C:\Users\admin\PycharmProjects\techdev\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
    'value': value})['value']
  File "C:\Users\admin\PycharmProjects\techdev\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\admin\PycharmProjects\techdev\venv\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response
    raise wde
selenium.common.exceptions.WebDriverException: Message: A session is either terminated or not started


Process finished with exit code 1

Appium server logs:

[Appium] Welcome to Appium v1.15.1
[Appium] Non-default server args:
[Appium]   allowInsecure: {
[Appium]   }
[Appium]   denyInsecure: {
[Appium]   }
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"alwaysMatch":{"platformName":"Windows"},"firstMatch":[{}]},"desiredCapabilities":{"deviceName":"M469727","app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","platformName":"Windows","newCommandTimeout":120}}
[W3C] Calling AppiumDriver.createSession() with args: [{"deviceName":"M469727","app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","platformName":"Windows","newCommandTimeout":120},null,{"alwaysMatch":{"platformName":"Windows"},"firstMatch":[{}]}]
[BaseDriver] Event 'newSessionRequested' logged at 1579165146979 (02:59:06 GMT-0600 (Central Standard Time))
[Appium] Could not parse W3C capabilities: 'deviceName' can't be blank
[Appium] Trying to fix W3C capabilities by merging them with JSONWP caps
[BaseDriver] The capabilities ["deviceName","app","newCommandTimeout"] are not standard capabilities and should have an extension prefix
[Appium] Appium v1.15.1 creating new WindowsDriver (v1.8.0) session
[BaseDriver] Creating session with MJSONWP desired capabilities: {
[BaseDriver]   "deviceName": "M469727",
[BaseDriver]   "app": "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App",
[BaseDriver]   "platformName": "Windows",
[BaseDriver]   "newCommandTimeout": 120
[BaseDriver] }
[BaseDriver] Session created with session id: e73341ec-1629-4976-a480-f6787eb5e7f6
[WinAppDriver] You must use WinAppDriver version 1.2-RC
[WinAppDriver] Verifying WinAppDriver version 1.2-RC is installed via comparing the checksum.
[WinAppDriver] WinAppDriver changed state to 'starting'
[WinAppDriver] Killing any old WinAppDrivers on same port, running: FOR /F "usebackq tokens=5" %a in (`netstat -nao ^| findstr /R /C:"4724 "`) do (FOR /F "usebackq" %b in (`TASKLIST /FI "PID eq %a" ^| findstr /I winappdriver.exe`) do (IF NOT %b=="" TASKKILL /F /PID %a))
[WinAppDriver] No old WinAppDrivers seemed to exist
[WinAppDriver] Spawning WinAppDriver with: 4724/wd/hub
[WinAppDriver] [STDOUT] Windows Application Driver listening for requests at: http://127.0.0.1:4724/wd/hub
[WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:4724/wd/hub/status] with no body
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] Address 'http://127.0.0.1:4724/wd/hub' is already in use
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] Failed to initialize: 0x80004005
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] ==========================================
[WinAppDriver] [STDOUT] GET /wd/hub/status HTTP/1.1
[WinAppDriver] [STDOUT] Accept: application/json, */*
[WinAppDriver] [STDOUT] Connection: close
[WinAppDriver] [STDOUT] Content-Type: application/json; charset=utf-8
[WinAppDriver] [STDOUT] Host: 127.0.0.1:4724
[WinAppDriver] [STDOUT] User-Agent: appium
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] HTTP/1.1 200 OK
[WinAppDriver] [STDOUT] Content-Length: 146
[WinAppDriver] [STDOUT] Content-Type: application/json
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] {"build":{"revision":"2002","time":"Wed Oct  2 21:08:40 2019","version":"1.2.1910"},"os":{"arch":"amd64","name":"windows","version":"10.0.17763"}}
[WD Proxy] Got response with status 200: {"build":{"revision":"2002","time":"Wed Oct  2 21:08:40 2019","version":"1.2.1910"},"os":{"arch":"amd64","name":"windows","version":"10.0.17763"}}
[WinAppDriver] Status call returned 200. we're online and ready to run tests
[WinAppDriver] WinAppDriver changed state to 'online'
[WinAppDriver] Starting WinAppDriver session. Will timeout in '20000' ms.
[WD Proxy] Matched '/session' to command name 'createSession'
[WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:4724/wd/hub/session] with body: {"desiredCapabilities":{"deviceName":"M469727","app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","platformName":"Windows","newCommandTimeout":120}}
[WinAppDriver] WinAppDriver exited unexpectedly with code 2147500037, signal null
[WinAppDriver] WinAppDriver changed state to 'stopped'
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] ==========================================
[WinAppDriver] [STDOUT] POST /wd/hub/session HTTP/1.1
[WinAppDriver] [STDOUT] Accept: application/json, */*
[WinAppDriver] [STDOUT] Connection: close
[WinAppDriver] [STDOUT] Content-Length: 151
[WinAppDriver] [STDOUT] Content-Type: application/json; charset=utf-8
[WinAppDriver] [STDOUT] Host: 127.0.0.1:4724
[WinAppDriver] [STDOUT] User-Agent: appium
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] HTTP/1.1 200 OK
[WinAppDriver] [STDOUT] Content-Length: 152
[WinAppDriver] [STDOUT] Content-Type: application/json
[WinAppDriver] [STDOUT] 
[WinAppDriver] [STDOUT] {"sessionId":"4C262CC3-21D9-4C2F-B669-98D5E03FFC69","status":0,"value":{"app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","platformName":"Windows"}}
[WD Proxy] Got response with status 200: {"sessionId":"4C262CC3-21D9-4C2F-B669-98D5E03FFC69","status":0,"value":{"app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","platformName":"Windows"}}
[WD Proxy] Determined the downstream protocol as 'MJSONWP'
[Appium] New WindowsDriver session created successfully, session e73341ec-1629-4976-a480-f6787eb5e7f6 added to master session list
[Appium] Closing session, cause was 'Unexpected shutdown'
[Appium] Removing session e73341ec-1629-4976-a480-f6787eb5e7f6 from our master session list
[BaseDriver] Event 'newSessionStarted' logged at 1579165162659 (02:59:22 GMT-0600 (Central Standard Time))
[MJSONWP (e73341ec)] Cached the protocol value 'MJSONWP' for the new session e73341ec-1629-4976-a480-f6787eb5e7f6
[MJSONWP (e73341ec)] Responding to client with driver.createSession() result: {"deviceName":"M469727","app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","platformName":"Windows","newCommandTimeout":120}
[HTTP] <-- POST /wd/hub/session 200 15687 ms - 199
[HTTP] 
[HTTP] --> POST /wd/hub/session/e73341ec-1629-4976-a480-f6787eb5e7f6/element
[HTTP] {"using":"name","sessionId":"e73341ec-1629-4976-a480-f6787eb5e7f6","value":"Seven"}
[MJSONWP (e73341ec)] Encountered internal error running command: NoSuchDriverError: A session is either terminated or not started
[MJSONWP (e73341ec)]     at asyncHandler (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:252:15)
[MJSONWP (e73341ec)]     at asyncHandler (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:432:15)
[MJSONWP (e73341ec)]     at Layer.handle [as handle_request] (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\layer.js:95:5)
[MJSONWP (e73341ec)]     at next (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\route.js:137:13)
[MJSONWP (e73341ec)]     at Route.dispatch (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\route.js:112:3)
[MJSONWP (e73341ec)]     at Layer.handle [as handle_request] (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\layer.js:95:5)
[MJSONWP (e73341ec)]     at C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:281:22
[MJSONWP (e73341ec)]     at param (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:354:14)
[MJSONWP (e73341ec)]     at param (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:365:14)
[MJSONWP (e73341ec)]     at Function.process_params (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:410:3)
[MJSONWP (e73341ec)]     at next (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:275:10)
[MJSONWP (e73341ec)]     at logger (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\morgan\index.js:144:5)
[MJSONWP (e73341ec)]     at Layer.handle [as handle_request] (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\layer.js:95:5)
[MJSONWP (e73341ec)]     at trim_prefix (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:317:13)
[MJSONWP (e73341ec)]     at C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:284:7
[MJSONWP (e73341ec)]     at Function.process_params (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:335:12)
[MJSONWP (e73341ec)]     at next (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:275:10)
[MJSONWP (e73341ec)]     at C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\body-parser\lib\read.js:130:5
[MJSONWP (e73341ec)]     at invokeCallback (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\raw-body\index.js:224:16)
[MJSONWP (e73341ec)]     at done (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\raw-body\index.js:213:7)
[MJSONWP (e73341ec)]     at IncomingMessage.onEnd (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\raw-body\index.js:273:7)
[MJSONWP (e73341ec)]     at IncomingMessage.emit (events.js:182:13)
[MJSONWP (e73341ec)]     at endReadableNT (_stream_readable.js:1090:12)
[MJSONWP (e73341ec)]     at process._tickCallback (internal/process/next_tick.js:63:19)
[HTTP] <-- POST /wd/hub/session/e73341ec-1629-4976-a480-f6787eb5e7f6/element 404 33 ms - 131
[HTTP] 

This code launches calculator but fails to perform click as it gives Getting selenium.common.exceptions.WebDriverException: Message: A session is either terminated or not started.

Details: Python version - 2.7, Python_appium_client version - 0.24, winapp driver version - 1.2,

Seeking help on this.

python
selenium
appium
winappdriver
asked on Stack Overflow Jan 16, 2020 by Musharib • edited Jan 16, 2020 by hongsy

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0