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

Client ignoring Capabilities and Bad Parameter Errors #924

Closed
FelixHahn opened this issue Jun 1, 2018 · 11 comments
Closed

Client ignoring Capabilities and Bad Parameter Errors #924

FelixHahn opened this issue Jun 1, 2018 · 11 comments
Assignees
Labels

Comments

@FelixHahn
Copy link

FelixHahn commented Jun 1, 2018

Description

The Java client seems to send the w3c desired capabilities in a wrong format so that the server throws an error. And the client is not sending some capabilities such as forceMjsonwp capability

Environment

  • java client: 6.0.0
  • Appium server: 1.8.2-beta
  • Desktop OS/version: Windows 7
  • Node.js version: 8.11.1
  • Mobile platform/version under test: Android
  • Real device: Google Pixel 2 (Androui 8.1) ans Samsung Galaxy S6 (Android 7.0)

Details

I always get a w3c bad parameter error if I want to set the implicit wait time outs.

[HTTP] --> POST /wd/hub/session/45e323c1-1248-4207-95b3-22a21ec5600f/timeouts
[HTTP] {"type":"implicit","ms":30000}
[debug] [W3C] Bad parameters: BadParametersError: Parameters were incorrect. We wanted "W3C prot
ad or implicit to be set" and you sent {"type":"implicit","ms":30000}
[HTTP] <-- POST /wd/hub/session/45e323c1-1248-4207-95b3-22a21ec5600f/timeouts 400 5 ms - 5372

Therefore I treid to force MJSONWP Protocol with forceMjsonwp capability. But forceMjsonwp capability is not send from java client to appium server. Seems like client is ignoring this capability.
If I try to add the forceMjsonwp capability manually into a session I created by hand with a rest client everything works fine.

I tried to set forceMjsonwp capability in both ways

capabilities.setCapability(MobileCapabilityType.FORCE_MJSONWP, true);

capabilities.setCapability("forceMjsonwp ", true);

Neither is send from client to server.

Code To Reproduce Issue

public AppiumDriver<?> setupAndroidDriver(String deviceID, String androidVersion, String appPackage, String activity, String appiumServer) throws MalformedURLException{

		DesiredCapabilities capabilities = new DesiredCapabilities(); 
		capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, deviceID); 
		capabilities.setCapability("udid", deviceID); 
		capabilities.setCapability(MobileCapabilityType.FORCE_MJSONWP, true);
		capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, androidVersion); 
		capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android"); 
		capabilities.setCapability("appWaitDuration", 20000); 
		capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
		capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
		capabilities.setCapability("appPackage", appPackage); 
		capabilities.setCapability("appActivity", activity); 
		capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");
		driver = new AppiumDriver<MobileElement>(new URL(appiumServer), capabilities);
		driver.manage().timeouts().implicitlyWait(30000, TimeUnit.MILLISECONDS);

		return driver;
	}

Link to Appium logs

https://gist.github.com/FelixHahn/93faef358769bebdd34f931303b5a1ba

@FelixHahn
Copy link
Author

Any meanings to this?

@SrinivasanTarget
Copy link
Member

@FelixHahn I will have a look at it soon

@SrinivasanTarget
Copy link
Member

SrinivasanTarget commented Jun 12, 2018

I couldn't reproduce it in 1.8.1 or in latest appium source in W3C mode but it does fails if we forceMJSWP.

@SrinivasanTarget
Copy link
Member

@dpgraham ping

@dpgraham
Copy link
Contributor

Can one of you assign this to me

@dpgraham
Copy link
Contributor

@SrinivasanTarget The forceMjsonwp was introduced in the Ruby client as way for the client to force usage of MJSONWP over W3C. When it's set to true it's supposed to exclude the capabilities: {alwaysMatch: {...}, firstMatch: [{...}, ...}] object from being sent

Does the Java client do that?

@SrinivasanTarget
Copy link
Member

@dpgraham if we set forceMjsonwp to true, payload will look as below from java client...

[HTTP] --> POST /wd/hub/session
[HTTP] {"desiredCapabilities":{"app":"/Users/ssekar/workspace/java-client/src/test/java/io/appium/java_client/ApiDemos-debug.apk","automationName":"UIAutomator2","platformName":"Android","deviceName":"Android Emulator"},"capabilities":{"alwaysMatch":{"platformName":"android"},"firstMatch":[{}]}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"/Users/ssekar/workspace/java-client/src/test/java/io/appium/java_client/ApiDemos-debug.apk","automationName":"UIAutomator2","platformName":"Android","deviceName":"Android Emulator"},null,{"alwaysMatch":{"platformName":"android"},"firstMatch":[{}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1528310015357 (00:03:35 GMT+0530 (IST))
[Appium] Could not parse W3C capabilities: 'deviceName' can't be blank. Falling back to JSONWP protocol.
[Appium] The following capabilities were provided in the JSONWP desired capabilities that are missing in W3C capabilities: ["app","automationName","platformName","deviceName"]. Falling back to JSONWP protocol.
[Appium] Creating new AndroidUiautomator2Driver (v1.12.0) session
[Appium] Capabilities:
[Appium]   app: /Users/ssekar/workspace/java-client/src/test/java/io/appium/java_client/ApiDemos-debug.apk
[Appium]   automationName: UIAutomator2
[Appium]   platformName: Android
[Appium]   deviceName: Android Emulator
[debug] [BaseDriver] Creating session with MJSONWP desired capabilities: {"app":"/Users/ssekar/works...
[BaseDriver] Session created with session id: 5b2fa500-f32d-4be9-906a-95e58b2a5ffd

@SrinivasanTarget
Copy link
Member

Do you expect the payload constructed by java client shouldn't contain Capabilities object at all if forceMjsonwp is set to true?

Also can you confirm the behavior in ruby client?

@dpgraham
Copy link
Contributor

@KazuCocoa How does the ruby_lib use forceMjsonwp? It omits the capabilities object, right?

@KazuCocoa
Copy link
Member

@dpgraham
Yes. in Ruby and Python client, I delete forceMjsonwp from desired capability. And if the property exists, { desiredCapabilities: desired_capabilities } will send instead of {alwaysMatch: {...}, firstMatch: [{...}, ...}

@dpgraham
Copy link
Contributor

@SrinivasanTarget just so you know, it's a non-standard capability, it's just there so that users can fall back to MJSONWP.

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

No branches or pull requests

4 participants