Device name required

Using appium android, we set device name as what get it from ‘adb devices’ command.
Can we change the same, s device name is some random number?
For multiple device execution it comes difficult to identify devices based on device name.
Can we set it like samsung tab A, sony experia, etc.

Pls suggest a solution for same,


First of all, Device Name is not the property which you have to set with the value from ADB. The value which you get from ADB has to be set in UDID property. Device Name can be anything, Appium doesn’t use it for identifying the device.

Also, if you use UDID property, you have to use Device Name property as well.

There are the following 2 cases, that you need to take care when working with UDID and Device ID.

Case 1: You have multiple devices but only 1 device is connected to your machine at a time : In such a scenario, there are 2 methods you can use -

Method 1: Just use DeviceName and don’t use UDID - In this case, you can give the device name as say My Phone. Since UDID property is not there, Appium will identify the device based on the number of connected devices. Since it finds only 1 device connected, it will run the script on that device, irrespective of what device name you give. Now if you remove the first device, and connect the second device, then also the script will work without changing the device name.

Method 2: Use both DeviceName and UDID - Here, you can give any value in deviceName but the UDID is what you get from ADB. If you remove the first device and connect the second, then you need to change the UDID as well, because Appium will see that connected device’s UDID is wrong if you dont change it. Here also you can keep the deviceName same when you switch between multiple devices.

Case 2 - You have connected multiple devices simultaneously - In this case, you have to set both UDID and DeviceName. This is because when Appium finds that multiple devices are connected, it will need the UDID to figure out on which device the scripts need to be run. Here, if you just provide DeviceName and no UDIDs, then Appium will throw an error as it wont be able to distinguish between the devices based on the device names.

1 Like

Thanks a lot for detailed response.
I actually want to understand case2, as defined by you.
Here, in adb devices command udid is occuring same for both devices. In such case how to proceed.
Please suggest.

If its occurring same for both devices, then maybe try changing the ID for one of the devices. I have not tried this As I haven’t encountered this issue.

Tried using solution provided here. But same is not working.
Second solution creates 2 entries of devices and also shows as unauthorised.

Just a follow up question. Is there a way to programatically get UDID of the connected device from the test script ?