Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make WebdriverIO to support native app testing on Windows with WinAppDriver #4369

Closed
wants to merge 3 commits into from
Closed

Make WebdriverIO to support native app testing on Windows with WinAppDriver #4369

wants to merge 3 commits into from

Conversation

licanhua
Copy link
Contributor

Proposed changes

WinAppDriver is a service to support Selenium-like UI Test Automation on Windows Applications.
For some message like click, the return message is {"sessionId":"19C1CE26-1887-4DA1-AD04-521307B5445C","status":0} which doesn't include value. then WebDriverIO consider it as failed message and will retry.
This pullrequest try to consider value is optional when status=0 to workaround WinAppDriver problem.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Reviewers: @webdriverio/technical-committee

licanhua and others added 2 commits August 15, 2019 11:56
A workaround for WinAppDriver. For some messages, WinAppDriver doesn't return value when status is 0.
@jsf-clabot
Copy link

jsf-clabot commented Aug 15, 2019

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Aug 15, 2019

Codecov Report

Merging #4369 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4369      +/-   ##
==========================================
+ Coverage   99.32%   99.32%   +<.01%     
==========================================
  Files         180      180              
  Lines        4414     4415       +1     
  Branches      950      951       +1     
==========================================
+ Hits         4384     4385       +1     
  Misses         27       27              
  Partials        3        3
Impacted Files Coverage Δ
packages/webdriver/src/utils.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ccb4fb5...c5ac4c8. Read the comment docs.

Copy link
Member

@mgrybyk mgrybyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got some thoughts on it.
Can it break somehow something else? When status is 0 for other drivers except of WinApp?

@@ -22,8 +22,14 @@ export function isSuccessfulResponse (statusCode, body) {
* response contains a body
*/
if (!body || typeof body.value === 'undefined') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think overall condition can be improved to avoid nested conditions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, and my first local copy is in one line.
splitting it to nested condition would make easy to read. Otherwise I have to write test case on it to provide more context.

@licanhua
Copy link
Contributor Author

Got some thoughts on it.
Can it break somehow something else? When status is 0 for other drivers except of WinApp?

I have no knowledge about other drivers.

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already had similar attempts to hotpatch WinAppDrivers incompatibility with the W3C protocol:

#3809
#4105

Also this time I will disagree with such a patch given that the fix should be applied there.

@@ -22,8 +22,14 @@ export function isSuccessfulResponse (statusCode, body) {
* response contains a body
*/
if (!body || typeof body.value === 'undefined') {
log.debug('request failed due to missing body')
return false
if (body && body.status === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (body

This will be always be true given that the parent if clause starts with

if (!body

return false
if (body && body.status === 0) {
/**
* A workaround for WinAppDriver. For some messages, WinAppDriver doesn't return value when status is 0.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed in WinAppDriver then. WebdriverIO follows the W3C standard and so should the driver.

@christian-bromann
Copy link
Member

Will close this as the issue should rather be fixed in WinAppDriver to follow the protocol rather than here.

@licanhua
Copy link
Contributor Author

licanhua commented Aug 30, 2019

For people who have the same problem, you can workaround the problem by customized webdriver.
I already create pull request to WinAppDriver, but we don't have ETA for the final release date. Please check if WinAppDriver there is a new release, this problem may be fixed.

    "webdriverio": "^5.10.1",
    "webdriver": "git+https://github.com/react-native-windows/webdriver.git",

@christian-bromann
Copy link
Member

For people who have the same problem, you can workaround the problem by customized webdriver.

I do not recommend using this custom webdriver build as it us more than 3 years old and not compatible with any recent WebdriverIO setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants