How to launch 2 devices with same deviceName?

Hi,

I need your help please.

I would like to run automation on 2 real devices (Android).
I am trying to automate all the process, so I run adb commands from my python code in order to extract the desired_caps.

I bought these 2 smartphones the same day in same shop. They have same “deviceName”:

The idea is to run some test on both smarthphones at same time.
I’ve understood I wil run appium on different port. But how Appium will know which smartphone is which one, if they have both same “deviceName”

Here is my code for the moment:
#— So now we will extract the ID and the deviceName from tmp.txt
#— We start first to extract all the lines in a list
with open(‘tmp.txt’) as f:
lines = f.readlines()

#--- then we can extract the id  in a list of dictionnary
#At the end, it hsould look somethign like this
#list = [
#    {'smartphone_ID': '41492968379078', 'deviceName': 'S6S5IN3G'},
#    {'smartphone_ID': '53519716736397', 'deviceName': 'S6S5IN3G'}
#]
i = 0
while(i<(quantity_connected_phones+1)):
    #--- We extract the ID
    if i!= 0 and i!=(quantity_connected_phones+1):
        first_space_pos = lines[i].find(' ')
        smartphone_id=lines[i][0:first_space_pos]
        dico_smartphones["Smartphone_ID"] = smartphone_id
        print("Smartphone " + str(i) + " id : " + smartphone_id)

    i += 1

print(str(dico_smartphones))
f.close()

Here is the output:

devices : List of devices attached
41492968379078 device product:S6S5IN3G model:S6S5IN3G device:S6S5IN3G transport_id:2
53519716736397 device product:S6S5IN3G model:S6S5IN3G device:S6S5IN3G transport_id:1

You have 2 smartphones connected on your computer.
If program didn’t detect some smartphones connected, please be sure to have enabled ‘USB debugging mode’ => read Configure on-device developer options  |  Android Studio  |  Android Developers.
Smartphone 1 id : 41492968379078
Smartphone 2 id : 53519716736397
{‘Smartphone_ID’: ‘53519716736397’}

Process finished with exit code 0

Is there anyone who faced this issue in the past? Any suggestion?

Thanks

  1. you can change device name on phone in settings.
  2. better point at correct device using UDID also. So try:
capabilities.setCapability(MobileCapabilityType.UDID,"41492968379078");

Thanks Aleksei.
I am in python. I searched on appium and google websites for finding hte python version of your line of code without success.

Do you know python?

https://github.com/appium/python-client/tree/master/test many examples

1 Like