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?
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?
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.
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.
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.
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).