fix(webdriverio): don't fail if getContext is not supported#13950
fix(webdriverio): don't fail if getContext is not supported#13950christian-bromann merged 4 commits intomainfrom
Conversation
eslint-plugin-wdio
@wdio/appium-service
@wdio/browser-runner
@wdio/allure-reporter
@wdio/browserstack-service
@wdio/cli
@wdio/concise-reporter
@wdio/config
@wdio/cucumber-framework
@wdio/firefox-profile-service
@wdio/dot-reporter
@wdio/globals
@wdio/jasmine-framework
@wdio/json-reporter
@wdio/junit-reporter
@wdio/lighthouse-service
@wdio/local-runner
@wdio/logger
@wdio/mocha-framework
@wdio/protocols
@wdio/repl
@wdio/reporter
@wdio/runner
@wdio/sauce-service
@wdio/shared-store-service
@wdio/smoke-test-cjs-service
@wdio/smoke-test-reporter
@wdio/smoke-test-service
@wdio/spec-reporter
@wdio/static-server-service
@wdio/sumologic-reporter
@wdio/testingbot-service
@wdio/types
@wdio/utils
@wdio/webdriver-mock-service
webdriver
webdriverio
commit: |
wswebcreation
left a comment
There was a problem hiding this comment.
Hi @christian-bromann , see my comment
| context : typeof context === 'object' ? | ||
| context.id : | ||
| undefined | ||
| const context = await this.#browser.getContext().catch((err) => { |
There was a problem hiding this comment.
Do you also have the context of when this happens, this is not something that should occur when using Appium, unless they are for example
- using wrong caps/WDIO gets back non W3C ones
- the driver is old as ...
There was a problem hiding this comment.
I think generally we can't make the assumption that just because a driver is considered as "mobile" they have the getContext command implemented. A driver can always fail to send the correct capabilities causing WebdriverIO to consider a session as mobile when it isn't. This patch will continue to log and elevate the problem but won't cause the whole session to fail.
What do you think?
There was a problem hiding this comment.
So my two-cents:
We then might need to:
- Fix the isMobile check to make it more robust
- Do this "fallback" for all commands
I also believe we can't "patch" the vendors (because this doesn't seem to be a specific Appium issue, unless a very old driver is used) if they don't return "valid" W3C responses.
There was a problem hiding this comment.
- Fix the isMobile check to make it more robust
We should totally strive for that but unfortunately can't rely on vendors implementing the specifications correctly.
- Do this "fallback" for all commands
What do you mean by "all commands"? If some one uses an unsupported command in their test, it should fail. However with these session manager (e.g. context, shadow root manager or the polyfill manager) we are enhancing WebdriverIO in the background and these things shouldn't cause the testrun to fail. Hence this patch which makes the context manager do nothing if getContext is not implemented.
if they don't return "valid" W3C responses.
I think this is not the issue. The issue is that the command is not implemented by the vendor or WebDriver server in which case we should disable the context manager.
There was a problem hiding this comment.
What do you mean by "all commands"? If some one uses an unsupported command
I mean for mobile commands specific commands. But I agree with what you say
I think this is not the issue. The issue is that the command is not implemented by the vendor or WebDriver server in which case we should disable the context manager.
I believe you just fixed this "not implemented by WebDriver" with #13949, so I wonder if this "fix" is still needed. I would then still let it fail and throw a different error message (maybe throw the capabilities that are used) to determine which drivers are not supporting this. Appium drivers (especially the most used ones) should support the "browser" commands AND the "native" commands. getContext is one of the oldest API's
Regarding the vendors, from what I now see LT is doing it differently, they default to JSONWP
and the W3C caps are not "Appium" proof
I'll put checking the vendors on my todo list so we can properly check if it's mobile based on the correct caps
There was a problem hiding this comment.
I believe you just fixed this "not implemented by WebDriver" with #13949, so I wonder if this "fix" is still needed.
I put up this patch because I am afraid we run into more issues where our mobile capability detection fails and causes a failure with the whole test run. I think this patch makes sense no matter what because we just disable the context manager in case the command fails.
There was a problem hiding this comment.
I believe you just fixed this "not implemented by WebDriver" with #13949, so I wonder if this "fix" is still needed.
I put up this patch because I am afraid we run into more issues where our mobile capability detection fails and causes a failure with the whole test run. I think this patch makes sense no matter what because we just disable the context manager in case the command fails.
Then can you add extra logs for debugging purposes so we can update the logic that is behind this when we get issues?
There was a problem hiding this comment.
What would you suggest aside from the
log.warn(`Error getting context: ${err}`)?
There was a problem hiding this comment.
Maybe also throw the requested capabilities so we can determine if the mobile checks have made an error
06e30b9 to
9eeec29
Compare
Proposed changes
We've had folks reporting that they get an error like this:
This patch mitigates this problem by just catching this error.
Types of changes
Checklist
Backport Request
//: # (The current
mainbranch is the development branch for WebdriverIO v9. If your change should be released to the current major version of WebdriverIO (v8), please raise another PR with the same changes against thev8branch.)v9and doesn't need to be back-ported#XXXXXFurther comments
n/a
Reviewers: @webdriverio/project-committers