Skip to content

fix: support context switching for wrapped Appium drivers on hybrid mobile apps (@W-23972736) - #245

Open
mnagamalla1 wants to merge 1 commit into
salesforce:devfrom
mnagamalla1:mobile-rtl-wrapped-driver-patch
Open

fix: support context switching for wrapped Appium drivers on hybrid mobile apps (@W-23972736)#245
mnagamalla1 wants to merge 1 commit into
salesforce:devfrom
mnagamalla1:mobile-rtl-wrapped-driver-patch

Conversation

@mnagamalla1

Copy link
Copy Markdown

Summary

WebDriverFactory.getAdapter chose WrappedDriverAdapter (web-only) for any WrappedDriverDecorator, even when the underlying WebDriver was an AppiumDriver. Mobile context switching (mobile: getContexts, SupportsContextSwitching) is only performed by MobileDriverAdapter, so wrapped Appium drivers never switched into the post-login WebView on hybrid apps.

Changes

  • WebDriverFactory.getAdapter checks WrappedDriverDecorator first; if the unwrapped driver is an AppiumDriver, returns the new WrappedMobileDriverAdapter.
  • New WrappedMobileDriverAdapter extends MobileDriverAdapter. getSeleniumDriver() returns the wrapped driver (so findElement flows through any wrapper-side smart finder); getAppiumDriver() returns the unwrapped AppiumDriver (so context switching operates on the real driver).
  • MobileDriverAdapter.getAppiumDriver(): final -> non-final, package-private -> protected, so subclasses in other packages can override.
  • WrappedElementAdapter constructor accepts DriverAdapter (was WrappedDriverAdapter) so it works with both web and mobile wrapped variants.

Test plan

  • `mvn clean install` on `utam-core` + `utam-compiler` passes locally (utam-core: 385 tests, utam-compiler: 633 tests).
  • Manual verification on a hybrid app: post-login WebView context switch works with a wrapped Appium driver.

@W-23972736

…ching

UTAM's WebDriverFactory.getAdapter chose WrappedDriverAdapter (web-only) for any
WrappedDriverDecorator, even when the underlying WebDriver was an AppiumDriver.
Mobile context switching (mobile: getContexts, SupportsContextSwitching) is only
performed by MobileDriverAdapter, so wrapped Appium drivers never switched into
the post-login WebView on hybrid apps.

Changes:
- WebDriverFactory.getAdapter checks WrappedDriverDecorator first; if the
  unwrapped driver is an AppiumDriver, returns the new WrappedMobileDriverAdapter.
- WrappedMobileDriverAdapter extends MobileDriverAdapter. getSeleniumDriver()
  returns the wrapped driver (so findElement flows through any wrapper-side
  smart finder); getAppiumDriver() returns the unwrapped AppiumDriver (so
  context switching operates on the real driver).
- MobileDriverAdapter.getAppiumDriver(): final -> protected, package-private ->
  protected, so subclasses in other packages can override.
- WrappedElementAdapter constructor accepts DriverAdapter (was
  WrappedDriverAdapter) so it works with both web and mobile wrapped variants.

Bumps version to 4.0.7-mobile-rtl-SNAPSHOT.

All 385 existing utam-core unit tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant