java-client
java-client copied to clipboard
Hitting org.openqa.selenium.UnsupportedCommandException: getCurrentContextHandle when doing driver.getContext() with java-client 4.21.0
Description
After this change on Java-client: https://github.com/appium/java-client/pull/2093 and on Selenium side: https://github.com/SeleniumHQ/selenium/commit/1b66415adf2bcce266d5acdd457378c4e6d07340. 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: https://github.com/SeleniumHQ/selenium/commit/1b66415adf2bcce266d5acdd457378c4e6d07340. While, change: https://github.com/appium/java-client/pull/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?
Please provide the full stack trace and the client code example. Are you sure you use the most recent client version?
We used java-client version 9.3.0, which depends on selenium 4.21.0.
@helenren Is this still an issue? If you could provide a way to reproduce this, with a code snippet, I can help look into it.
We have upgraded to java-client 9.3.0, not hit this issue anymore. Thanks for checking.
On Mon, Jul 7, 2025 at 4:45 AM Puja Jagani @.***> wrote:
pujagani left a comment (appium/java-client#2234) https://github.com/appium/java-client/issues/2234#issuecomment-3044665729
@helenren https://github.com/helenren Is this still an issue? If you could provide a way to reproduce this, with a code snippet, I can help look into it.
— Reply to this email directly, view it on GitHub https://github.com/appium/java-client/issues/2234#issuecomment-3044665729, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSEK6DNJVQFWWNJTPI2XMD3HJMUFAVCNFSM6AAAAACA6ALL32VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTANBUGY3DKNZSHE . You are receiving this because you were mentioned.Message ID: @.***>
--
https://smart.salesforce.com/sig/qren//us_mb/default/link.html