Conversation
|
I'm not sure if you like my way to handle the way to be able to overwrite the session-flag, but it was the easiest way without too much code impact and , imho, the least impact.
|
eslint-plugin-wdio
@wdio/allure-reporter
@wdio/appium-service
@wdio/browser-runner
@wdio/browserstack-service
@wdio/cli
@wdio/concise-reporter
@wdio/config
@wdio/cucumber-framework
@wdio/dot-reporter
@wdio/firefox-profile-service
@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: |
The mobileContext will provide the context in which the app is, this is depending on browser/app
| this.#currentContext = context | ||
| if (this.#browser.isMobile) { | ||
| this.#browser.isNativeContext = context ? context === 'NATIVE_APP' : this.#browser.isNativeContext | ||
| this.#browser.mobileContext = context || undefined |
There was a problem hiding this comment.
Not sure why I'm getting an error Property 'mobileContext' does not exist on type 'Browser'. here. I've added it to the types, but might be missing something
- simplified `mobileContext` - fixed setting the property in the monad - updated the tests - only set the context for mobile
- revert UT's
christian-bromann
left a comment
There was a problem hiding this comment.
Some comments. My main request would be to move this into the webdriverio package and handle this flag as a getter returning a dynamic value based on the context manager. See #13896 where I do the same for the isBidi flag.
| | `isMobile` | `Boolean` | Indicates a mobile session. See more under [Mobile Flags](#mobile-flags). | | ||
| | `isIOS` | `Boolean` | Indicates an iOS session. See more under [Mobile Flags](#mobile-flags). | | ||
| | `isAndroid` | `Boolean` | Indicates an Android session. See more under [Mobile Flags](#mobile-flags). | | ||
| | `isNativeContext` | `Boolean` | Indicates if the mobile is in the `NATIVE_APP` context. See more under [Mobile Flags](#mobile-flags). | |
There was a problem hiding this comment.
Can we add isBidi here as we forgot about it.
| isNativeContext: { value: isNativeContext }, | ||
| mobileContext: { value: mobileContext }, |
There was a problem hiding this comment.
We should define these environment flags in the webdriverio package instead. This will allow use to manage this value dynamically through the context manager, e.g.
| isNativeContext: { value: isNativeContext }, | |
| mobileContext: { value: mobileContext }, | |
| isNativeContext: { get: function () { | |
| const context = getContextManager(this) | |
| return context.isNativeContext | |
| } }, |
We should avoid having both flags being writeable as we don't want users mess around with it. I think we can achieve this easily with proposed approach. I suggest adding these flags here.
There was a problem hiding this comment.
Thanks, will fix this
| /** | ||
| * We need to be able to overwrite some properties in case it changes during the session | ||
| */ | ||
| const writableProperties = ['isNativeContext', 'mobileContext'] | ||
| writableProperties.forEach((property) => { | ||
| propertiesObject[property] = { | ||
| value: propertiesObject[property]?.value, | ||
| writable: true, | ||
| configurable: true, | ||
| } | ||
| }) |
There was a problem hiding this comment.
Then we can remove this.
| // We can only determine it for Android and Chrome, for all other, including iOS, we return undefined | ||
| isAndroid(capabilities) && capabilities?.browserName?.toLowerCase() === 'chrome' ? 'CHROMIUM' : | ||
| undefined | ||
| } |
There was a problem hiding this comment.
And move this into the ContextManager class to compute the initial value.
|
Thanks for the feedback @christian-bromann , will work on it and fix it |
This PR adds new session flags called
isNativeContextandmobileContext. These flags will tell you ifIt also reverts the extra WebDriver-call that was added to the
implicitWaitadnd use theisNativeContextflagThey will automatically change if the context changes
Given this config:
You can access these flags like all other (mobile) flags in your test like so:
Because it's attached to the
contextManagerit will also update the status if you do this based on the below configProposed changes
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
Reviewers: @webdriverio/project-committers