I am using Appium to automate my UI tests on Android.
I have a physical device connected to my computer, and an emulator launched from Android Studio:
$ adb devices
List of devices attached
0831bd3b21320609 no permissions (My phiscal Nexus 5)
emulator-5554 device (My Emulated device)
When I launch Appium and run my tests it picks up my phisical device. Appium Logs:
[debug] [ADB] Running '/home/babken/android-sdk/platform-tools/adb' with args: ["-P",5037,"-s","0831bd3b21320609","wait-for-device"]
[debug] [ADB] Restarting adb
[debug] [ADB] Killing adb server on port 5037
[debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
...
The tests hang and I get an error because it connects to the wrong device.
I have this in my appium capabilities:
desired_caps = {
'platformName': 'Android',
'deviceName': 'Android Device',
'autoGrantPermissions': True,
'app': apk_location,
'newCommandTimeout': 36000,
}
I know I can set the udid
capability to emulator-5554
but the emulator's name can change.
As a workaround I can also plug off my Nexus or turn off usb debugging but that's not a solution for me.