Hello there,
I’m not sure how far custom capabilities are supported in Appium. I tell you my workaround and the point I got stucked:
The environment
I’ve setup a Selenium Grid 3.14.0 with Appium nodes 1.9.0. Each Appium node is started on a unique port (–port flag) and attached to a mobile device through nodeconfig json capabilities like this:
{
"capabilities":[
{
"deviceName":"Galaxy A5",
"platformName":"Android",
"platformVersion":"7.0.0",
"udid":"3300f48a1a8e831b",
"groups":"wallet;retail;empresas;bizum",
"maxInstances":1
}
],
"configuration":{
"cleanUpCycle":2000,
"proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://localhost:4723/wd/hub",
"maxSession":1,
"register":true,
"registerCycle":5000,
"hubPort":"4723",
"hubHost":"localhost"
}
}
Notice that I’ve defined a custom homemade capability named groups. Obviously I have a custom capabilities matcher for grid’s hub and its properly linked through hub’s json config file. The capabilities matcher is needed at the moment I want to select nodes by the custom groups capability.
When I start grid’s hub and multiple Appium servers (nodes) all is working fine. Appium nodes register into grid hub and every log seems to be normal.
The problem
At the client side, Java in my case, I create a AndroidDriver object with the following capabilities:
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability("deviceName", "Appium grid device");
dc.setCapability("appPackage", "com.mycompany.MyApp");
dc.setCapability("appActivity", "com.mycompany.MyApp.StartActivity");
dc.setCapability("automationName", "uiautomator2");
dc.setCapability("platformName", "Android");
dc.setCapability("groups", "wallet");
AndroidDriver<WebElement> driver = new AndroidDriver<WebElement>(new URL("http://localhost:4723/wd/hub"), dc);
All seems to be normal except “groups” custom capability: It’s intended to match a ‘wallet’ node with this driver instance.
At the time I try to execute it throws a very nested exceptions with bad looking messages:
- WebDriverException: It is impossible to create a new session because ‘createSession’ which takes HttpClient, InputStream and long was not found or it is not accessible
- GridException: Cannot extract a capabilities from the request
- IllegalArgumentException: Illegal key values seen in w3c capabilities: [groups]
(I omitted some nested levels, there is a lot and repetitives. If you want to see the full exception stacktrace please claim it to me).
Bad luck on me! I excpected to make this work and it just rejected my custom capability at the client side. How I know that exceptions are throwed at client side? Because I removed the capability “groups” from node json configuration file and the result is the same, while the grid environment is up and running without weird messages.
So…
My question is
There is supported custom capabilities at Appium client side??
There is some way to inject custom capabilities to a driver creation for hub’s capabilities matching logics??
There exists some workaround to achieve what I want?? (extra custom capabilities for a more complex client and node matching).
Any suggestion are welcomed!
Thank you very munch.