Reputation: 11
The problem
I am using Android Studio to run Appium tests. Through AVD manager I have two emulators one for Nexus and the other for Pixel. If I want to run tests on my Nexus it always run on Pixel. Not sure why.
Environment
Appium version: v1.6.5
Last Appium version that did not exhibit the issue (if applicable):
Desktop OS/version used to run Appium: Windows 7
Mobile platform/version under test: Android 7.1.1
Real device or emulator/simulator: Emulator
Android Studio Version: 2.3.3
Details
I am using Android Studio to run Appium tests. Through AVD manager I have two emulators one for Nexus and the other for Pixel. If I want to run tests on my Nexus it always run on Pixel. Not sure why. I am setting up the device using Desired capabilities and the device name is of no use to differentiate the device. Eventhough I have specified Nexus device name, it always runs on Pixel. I have first created Nexus emulator through Android AVD Manager and the Pixel later.
Code To Reproduce Issue
Device configuration:
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("deviceName", "Nexus_5X_API_25");
desiredCapabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
desiredCapabilities.setCapability(CapabilityType.VERSION, "7.1.1");
desiredCapabilities.setCapability("platformName", "Android");
desiredCapabilities.setCapability("appPackage", "com.android.calculator2");
desiredCapabilities.setCapability("appActivity", "com.android.calculator2.Calculator");
driver1 = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), desiredCapabilities);
driver1.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
Device list on using command line
C:\Users\balnanad>android list avd
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools\bin\sdkmanager.bat
and tools\bin\avdmanager.bat
Invoking "C:\Users\balnanad\AppData\Local\Android\sdk\tools\bin\avdmanag avd
Available Android Virtual Devices:
Name: Nexus_5X_API_25
Device: Nexus 5X (Google)
Path: C:\Users\balnanad.android\avd\Nexus_5X_API_25.avd
Target: Google APIs (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
Skin: nexus_5x
Sdcard: 100M
Name: Pixel_XL_API_25
Device: pixel_xl (Google)
Path: C:\Users\balnanad.android\avd\Pixel_XL_API_25.avd
Target: Google APIs (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
Skin: pixel_xl
Sdcard: 100M
C:\Users\balnanad>
Upvotes: 1
Views: 643
Reputation: 1899
Add udid as well
desiredCapabilities.setCapability("udid", "Nexus_5X_API_25")
Upvotes: 2