appium/java-client

Did you stop prefixing capabilities with 'appium:' in the latest java client?

Closed this issue · 4 comments

Description

We are noticing that in 9.2.3, the java client is no more appending prefix 'appium:' to the capabilities when we set those using DesiredCapabilities class. Is this intentional or a bug?

Environment

  • Java client build version or git revision if you use some snapshot: 9.2.3
  • Appium server version or git revision if you use some snapshot: Latest
  • Desktop OS/version used to run Appium if necessary: Mac OS
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: 21
  • Mobile platform/version under test: Android 14
  • Real device or emulator/simulator: Both

Code To Reproduce Issue [ Good To Have ]

Set capabilities as well and try to create a driver session:

DesiredCapabilities caps =new DesiredCapabilities();
caps.setCapability("platformName", "Android");
caps.setCapability("deviceName", "device_name");
caps.setCapability("automationName", "UiAutomator2");
caps.setCapability("udid", "emulator-5554");
caps.setCapability("app", "file_path");

Exception Stacktraces

You can see in the exception trace, the client hasn't appended 'appium:' prefix to the capabilities.

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Host info: host: 'name', ip: 'ip'Build info: version: '4.21.0', revision: '79ed462ef4'System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '14.5', java.version: '17.0.8'Driver info: io.appium.java_client.android.AndroidDriverCommand: [null, newSession {capabilities=[Capabilities {app: /file_path..., automationName: UiAutomator2, deviceName:device_name, platformName: ANDROID, udid: emulator-5554}]}]Capabilities {app: /file_path..., automationName: UiAutomator2, deviceName:device_name, platformName: ANDROID, udid: emulator-5554} at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:536) at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:270) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:161) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:91) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:103) at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:109) at sampleoad.run.main(run.java:33)Caused by: java.lang.IllegalArgumentException: Illegal key values seen in w3c capabilities: [app, automationName, deviceName, udid] at org.openqa.selenium.remote.NewSessionPayload.lambda$validate$5(NewSessionPayload.java:163) at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:540) at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:541) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:541) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at org.openqa.selenium.remote.NewSessionPayload.validate(NewSessionPayload.java:167) at org.openqa.selenium.remote.NewSessionPayload.(NewSessionPayload.java:70) at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:99) at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:84) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:60) at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:176)

Link To Appium Logs

The client errors out before sending the request to the server.

This is expected. In the recent version we have removed several ugly hacks that were needed to fix the interoperability with Selenium lib, which resulted into the above behaviour. Consider using documented Options wrappers from java client lib for automatic capability names patching: https://github.com/appium/java-client?tab=readme-ov-file#usage-examples

Got it. Thank you.

Thanks, this helped. A breaking change should have been 9.3.0 not a patch version really.