Running same Appium tests with different desired capabilities

Hi there,

I have a test suite put together using Appium with Cucumber. I have run all the tests successfully. I set the desired capabilities in the code, but would like instead to be able to parameterise these so that I can run the same tests against different desired capabilities. Is it possible to do this from a Mac?

Cheers, Charlie

How are you expressing the capabilities in your code? My tests are written in Ruby, and we express the capabilities (except UUID which we get dynamically from the device) in settings files. Our settings files are setup like this:

config.yml <-Defaults. This is committed to the repository. Settings are stored as a hash.

override.yml <-Any overrides. Added to .gitignore, not committed to the repository. Anything in this file overrides the defaults in config.yml.

command line parameters <-Override any other setting. So if I wanted to override ‘platformName’ here I could do it with ‘-platformName’.

If I were to tackle your problem with the above settings I would probably use the command line parameters to do so as it’s the most dynamic of the three. Without understanding your code I’m not sure I could give you advice in one way or another.

Thanks for the reply! Ended up using the terminal command line to set capabilities e.g. appium --device-name ‘iPhone 6’.

This seems to work and the appium console states:
info: [debug] Non-default server args: {“deviceName”:“iPhone 6”}

However, when I run my code with deviceName commented out, it doesn’t pick up the deviceName from the terminal session. Any ideas why not? Might be because I create a separate instance of DesiredCapabilities?

// App: Simulator
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“platformVersion”, “8.1”);
//capabilities.setCapability(“deviceName”, “iPhone 6”);
//capabilities.setCapability(“deviceName”, “iPad 2”);
capabilities.setCapability(“app”, “/Users/charlies/Desktop/”);

	try {
		driver = new IOSDriver(new URL(""), capabilities);
	} catch (MalformedURLException e) {
	driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

Interesting. Could be the separate instance. Can you run your tests without that?

Otherwise, I’d look at the code that handles capabilities. If you specify it on the command line only, does it add the key/value pair to the hash? If you use an IDE you could watch the DesiredCapabilities instance and determine this easily. I’m making a couple of assumptions here so I might be a little off base but I think the theory is solid.

Hi there,

If I exclude the capabilities from my code (only add them in the terminal) then the tests crash and say that ‘deviceName’ was missing.

Can you give an example of the command line arguments you are passing? You may need to pass ‘platformVersion’ as well as ‘deviceName’. Could be a bug, but I’m not sure.

Hi there,

Here is an example of the terminal command I use:
appium --device-name ‘iPhone 6’ --platform-version 8.1

And here is the error:
error: The following desired capabilities are required, but were not provided: deviceName

Hmm. Not sure here. Personally I start the server with more capabilities than that, but that doesn’t seem to be your problem. Also, I use a node command to start the server. Maybe there is someone else who runs things more like you do that can answer this.

Thanks for the reply - much appreciated.
Out of interest, how do you use the node to start the server? Sorry never heard of this method.

Yeah, I’m sorry I’m not more of a help here. For the node command, our basic start command is ‘node node_modules/appium --log-timestamp’. I then add the other needed parameters according to a decision tree that reads mainly from our settings file(s).

Ah ok. Thanks very much for all the input Wreed. Much appreciated.