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

Hitting org.openqa.selenium.UnsupportedCommandException: getCurrentContextHandle when doing driver.getContext() with java-client 4.21.0 #2234

Open
helenren opened this issue Sep 19, 2024 · 2 comments

Comments

@helenren
Copy link

Description

After this change on Java-client: #2093 and on Selenium side: SeleniumHQ/selenium@1b66415. Our test fail when doing getContext().

Environment

  • Java client build version or git revision if you use some snapshot: 4.21.0
  • Appium server version or git revision if you use some snapshot: 2.11.0
  • Desktop OS/version used to run Appium if necessary:
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe:
  • Mobile platform/version under test: iOS and Android any versions
  • Real device or emulator/simulator: both

Details

Stack Trace:

at org.openqa.selenium.remote.codec.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:237)
at org.openqa.selenium.remote.codec.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:111)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:178)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:237)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:591)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:307)
at io.appium.java_client.remote.SupportsContextSwitching.getContext(SupportsContextSwitching.java:78)

With debug, I noticed that nameToSpec does not include any mobile-specific commands because of the change: SeleniumHQ/selenium@1b66415. While, change: #2093 added that mobile command in the MobileCommand class, but the commands in commandRepository have not been injected. Therefore AbstractHttpCommandCodec cannot find commands, like getCurrentContextHandle.

We created a customized version of AppiumCommandExecutor and added those commands as additional commands to make it work. Since context switching commands are critical for mobile hybrid application tests, those commands would be supported by default, right? Is there anything that I missed when trying to use AppiumCommandExecutor for testing hybrid mobile application tests?

@mykola-mokhnach
Copy link
Contributor

Please provide the full stack trace and the client code example. Are you sure you use the most recent client version?

@helenren
Copy link
Author

We used java-client version 9.3.0, which depends on selenium 4.21.0.

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

No branches or pull requests

3 participants