Skip to content

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

Open
@helenren

Description

@helenren

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions