As we mentioned before, Desired Capabilities are keys and values encoded in a JSON object, sent by Appium clients to the server when a new automation session is required.
Desired Capabilities can be scripted in the WebDriver test in our test script or set within the Appium Server GUI via an inspector session.
For example here, this is the inspector session with Appium Server, when we start inspecting or want to add desired capabilities here in the inspector session with Appium server and to start our session.
Here you can click on "Desired Capabilities Documentation" to know the required desired capabilities because we have optional and required desired capabilities.
Without the required, we can't start our session.
Usually, we are using the device ID or the device name and our desired capabilities to be able to start a new session with the Appium server.
For example, in iOS, from the command line, we can use this command to list our iOS simulator device’s information on our machine, and also, we can find the UDID in this schema.
xcrun simctl list
I have already installed or prepared one simulator - here is iPhone 12 Pro Max.
From the command line, I will run the command.
This will display all the simulators on my machine, but for the one that is already open, I will find that it says "Booted".
I can take this UDID and use it in the desired capabilities.
So this is the iPhone 12 Pro Max, which is the current device that I'm using.
For Android, we can also use a command from the command line, but first, we should launch our device and then run adb
to list our devices.
So we can run:
adb devices
Then, the output will be the device ID and the type is the device.
I already have one emulator that's open, and I will run the command.
Then, it will give us a list of devices attached to our machines.
If we have different devices - if we have a physical device already attached using a USB cable, it will also be displayed with this link.
So, emulator-5554
is the name of the emulator, and the type is device
.
Appium Desktop offers an inspector that you can use to look up or locate elements of an application.
Once you add the Desired Capabilities and then click "Start Session", you can start to inspect the elements.
It also lets you perform basic actions on these elements, such as tap and send keys.
So for example here, after we click the "Start Session" button, we will have the inspector session here.
If you click, for example, on this element, or on this button, you will find here the App Source and you will find the elements, and once you click on this element, you can find your "accessibility id", the "xpath", or you can also do a "Tap" or "Send Keys" or "Clear", or you can copy anything from this.
So Tap if it's a button, and Send Keys if it is a text box.
So this is the Appium Inspector session with Appium Desktop, and it helps us to find the accessibility or the selector IDs for our elements, and you can use it in our code.
Quiz
The quiz for this chapter can be found in Chapter 4.8