Android real device and android emulator


#1

Hi,
I have some problem to run my tests. I have some test case that I need to run it on android emulator but if the real device will be connected this test case will be run on the real device but in desired capabilities I set emulator. How I can cancel default device in appium?

d_c = {
‘platformName’: ‘Android’,
‘deviceName’: ‘emulator-5554’,
‘app’: PATH_TO_ANDROID_APP,
# ‘unicodeKeyboard’: True,
# ‘resetKeyboard’: True,
‘automationName’: ‘uiautomator2’,
‘noReset’: True,
‘newCommandTimeout’: 480,
}
device = webdriver.Remote(‘http://0.0.0.0:4723/wd/hub’, desired_capabilities=d_c)


#2

set the deviceName to ‘null’ to use the first available device (either real or emulator)


#4

I saw in this discussion my problem:


but it’s not work for me.


#5

Hi,
Thank you for your answer.
The problem is that I set in deviceName emulator, why the appium run my test on a real device instead of the emulator?
The real device is connected and USB debugging is working but why when I set in deviceName the emulator the appium is run my test on the real device?
I meat I want to use with device that I set in deviceName not something default.


#6

because devices are distinguished by their UIDs, not by names. See https://github.com/appium/appium/issues/12202