microsoft / WinAppDriver

Windows Application Driver
MIT License
3.66k stars 1.4k forks source link

WinAppDriver needs to include **value** key on the response object even when value is NULL ( e.g. return obj for actions like click). #740

Open satishautade opened 5 years ago

satishautade commented 5 years ago

I recently started using the WebDriverIO/Appium for automating Windows native apps using WinAppDriver. My test setup looks like following:

webdriverio <=> Appium server <=> WinAppDriver
  (v5.1.7)        (v1.13.0)          (v1.5.1)

Webdriver IO module interpretes a command to have failed, if response object returned from a driver does NOT have a value. Refer: https://github.com/webdriverio/webdriverio/blob/67aa4d5296f60448a8ccccc43fa0fa9064a67bd6/packages/webdriver/src/utils.js#L23

I raised a bug in webdriverio project about this here. But the resolutions seems to be on the WinAppDriver side (https://github.com/webdriverio/webdriverio/issues/4105#issuecomment-504342332). Please refer to comments on this issue. Hence raising it here.

Scenario that fails: When using webdriverio commands like 'click' or 'setValue', I see these actions being executed successfully on the application under test but webdriverio test fails with unknown error.

WDIO test logs below:

0-0] 2019-06-21T05:08:59.772Z INFO webdriver: RESULT { ELEMENT: '742cae43-a5a9-4c74-8250-7e6532bec409' }
[0-0] 2019-06-21T05:08:59.778Z INFO webdriver: COMMAND elementClick("742cae43-a5a9-4c74-8250-7e6532bec409")
[0-0] 2019-06-21T05:08:59.778Z INFO webdriver: [POST] http://10.4.34.186:4723/wd/hub/session/bd2b4751-0c0d-45f9-a698-7cecee8a96de/element/742cae43-a5a9-4c74-8250-7e6532bec409/click
[0-0] 2019-06-21T05:09:00.146Z WARN webdriver: Request failed due to unknown error
[0-0] 2019-06-21T05:09:00.146Z INFO webdriver: Retrying 1/3
2019-06-21T05:09:00.146Z INFO webdriver: [POST] http://10.4.34.186:4723/wd/hub/session/bd2b4751-0c0d-45f9-a698-7cecee8a96de/element/742cae43-a5a9-4c74-8250-7e6532bec409/click
[0-0] 2019-06-21T05:09:01.037Z WARN webdriver: Request failed due to unknown error
[0-0] 2019-06-21T05:09:01.037Z INFO webdriver: Retrying 2/3
2019-06-21T05:09:01.037Z INFO webdriver: [POST] http://10.4.34.186:4723/wd/hub/session/bd2b4751-0c0d-45f9-a698-7cecee8a96de/element/742cae43-a5a9-4c74-8250-7e6532bec409/click
[0-0] 2019-06-21T05:09:01.913Z WARN webdriver: Request failed due to unknown error
[0-0] 2019-06-21T05:09:01.913Z INFO webdriver: Retrying 3/3
2019-06-21T05:09:01.914Z INFO webdriver: [POST] http://10.4.34.186:4723/wd/hub/session/bd2b4751-0c0d-45f9-a698-7cecee8a96de/element/742cae43-a5a9-4c74-8250-7e6532bec409/click
[0-0] 2019-06-21T05:09:02.775Z ERROR webdriver: Request failed due to Error: unknown error
    at getErrorFromResponseBody (/home/satish/projects/webdriver-io/node_modules/webdriver/build/utils.js:347:12)
    at Request._callback (/home/satish/projects/webdriver-io/node_modules/webdriver/build/request.js:121:64)
    at Request.self.callback (/home/satish/projects/webdriver-io/node_modules/request/request.js:185:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/home/satish/projects/webdriver-io/node_modules/request/request.js:1161:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/home/satish/projects/webdriver-io/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:313:30)
[0-0] Error in "MedAdvisor Clinic Desktop (ozdocs sidebar) should launch the application"
unknown error

To Reproduce I have provided all the example logs from WinAppDriver/Appium side and WDIO Test runner side. Happy to create a github project but, at the moment, I don't believe that its strictly needed.

Expected behavior Since the commands are interacting with the application successfully, WDIO test should not return any error. It should just pass.

Log

When I looked closely at the Appium server logs, I noticed webdriverio commands that perform actions like click or setValue, do not have a value property in the object returned. e.g.

{"sessionId":"89AD0463-E87A-49CB-ABA1-16EDB3D57DE6","status":0}  //note there is no 'value' property

Appium server log below:

[HTTP] --> POST /wd/hub/session/ee42f592-ffd2-4870-a2d0-edf8b276da3e/element/42.2753192/value
[HTTP] {"text":"asdfASDF12!@","value":["a","s","d","f","A","S","D","F","1","2","!","@"]}
[MJSONWP (ee42f592)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched '/wd/hub/session/ee42f592-ffd2-4870-a2d0-edf8b276da3e/element/42.2753192/value' to command name 'setValue'
[debug] [WD Proxy] Proxying [POST /wd/hub/session/ee42f592-ffd2-4870-a2d0-edf8b276da3e/element/42.2753192/value] to [POST http://127.0.0.1:4724/wd/hub/session/89AD0463-E87A-49CB-ABA1-16EDB3D57DE6/element/42.2753192/value] with body: {"text":"asdfASDF12!@","value":["a","s","d","f","A","S","D","F","1","2","!","@"]}
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] ==========================================
[WinAppDriver] [STDOUT] POST /wd/hub/session/89AD0463-E87A-49CB-ABA1-16EDB3D57DE6/element/42.2753192/value HTTP/1.1
[WinAppDriver] [STDOUT] Accept: application/json, */*
[WinAppDriver] [STDOUT] Connection: close
[WinAppDriver] [STDOUT] Content-Length: 81
[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: 63
[WinAppDriver] [STDOUT] Content-Type: application/json
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] {"sessionId":"89AD0463-E87A-49CB-ABA1-16EDB3D57DE6","status":0}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"89AD0463-E87A-49CB-ABA1-16EDB3D57DE6","status":0}
[WD Proxy] Replacing sessionId 89AD0463-E87A-49CB-ABA1-16EDB3D57DE6 with ee42f592-ffd2-4870-a2d0-edf8b276da3e
[HTTP] <-- POST /wd/hub/session/ee42f592-ffd2-4870-a2d0-edf8b276da3e/element/42.2753192/value 200 793 ms - 63
[HTTP]

Compare this with other commands that query the application for an element or text, for these commands, underlying WinAppDriver seems to set the value property on the returned object. e.g.

{"sessionId":"89AD0463-E87A-49CB-ABA1-16EDB3D57DE6","status":0,"value":{"ELEMENT":"42.1115122"}} // note the value is set to an object containing element found

Appium server log below:

[HTTP] --> POST /wd/hub/session/ee42f592-ffd2-4870-a2d0-edf8b276da3e/element
[HTTP] {"using":"accessibility id","value":"btnSignIn"}
[MJSONWP (ee42f592)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched '/wd/hub/session/ee42f592-ffd2-4870-a2d0-edf8b276da3e/element' to command name 'findElement'
[debug] [WD Proxy] Proxying [POST /wd/hub/session/ee42f592-ffd2-4870-a2d0-edf8b276da3e/element] to [POST http://127.0.0.1:4724/wd/hub/session/89AD0463-E87A-49CB-ABA1-16EDB3D57DE6/element] with body: {"using":"accessibility id","value":"btnSignIn"}
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] ==========================================
[WinAppDriver] [STDOUT] POST /wd/hub/session/89AD0463-E87A-49CB-ABA1-16EDB3D57DE6/element HTTP/1.1
[WinAppDriver] [STDOUT] Accept: application/json, */*
[WinAppDriver] [STDOUT] Connection: close
[WinAppDriver] [STDOUT] Content-Length: 48
[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] {"using":"accessibility id","value":"btnSignIn"}
[WinAppDriver] [STDOUT] HTTP/1.1 200 OK
[WinAppDriver] [STDOUT] Content-Length: 96
[WinAppDriver] [STDOUT] Content-Type: application/json
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] {"sessionId":"89AD0463-E87A-49CB-ABA1-16EDB3D57DE6","status":0,"value":{"ELEMENT":"42.1115122"}}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"89AD0463-E87A-49CB-ABA1-16EDB3D57DE6","status":0,"value":{"ELEMENT":"42.1115122"}}
[WD Proxy] Replacing sessionId 89AD0463-E87A-49CB-ABA1-16EDB3D57DE6 with ee42f592-ffd2-4870-a2d0-edf8b276da3e
[HTTP] <-- POST /wd/hub/session/ee42f592-ffd2-4870-a2d0-edf8b276da3e/element 200 224 ms - 96
[HTTP]
satishautade commented 5 years ago

@hassanuz : It has been quite some time and I wonder if this issue has caught anyone's attention yet? Resolution to this issue is critical for us to move ahead with WinAppDriver. We want to be able to write our test code in Javascript using WebDriverIO framework. Any help on this issue would be much appreciated.

Thanks, Satish.

andrerleao commented 5 years ago

Its same for me.

I can´t use WinAppDriver with webdriverIO