I have configured two android device in my machine. One is real android device (ZX1D63R33N)[Moto G Second Gen - With 5.0.2 - API 21] and GenyMotion android emulator [With 5.1.1 with API 22].
Script get executed in both device successfully. But i'm not able to control the execution in which device i should perform the execution.
Consider I connect my real android device first and start the Genymotion emulator second. then adb device will give the following output.
C:\Users\Ramkumar>adb devices
List of devices attached
ZX1D63R33N device
192.168.56.101:5555 device
I have set the following SelendoidCapabilities in my script.
WebDriver driver; //AppiumDriver driver
//new SelendroidCapabilities.
SelendroidCapabilities selendroidCapabilities = SelendroidCapabilities.emulator(DeviceTargetPlatform.ANDROID22, "Android Emulator");
selendroidCapabilities.setEmulator(true);
selendroidCapabilities.setCapability("browserName", "Chrome");
selendroidCapabilities.setCapability("device", "Android");
selendroidCapabilities.setCapability("version", "5.1");
selendroidCapabilities.setCapability("deviceName", "192.168.56.101:5555");
selendroidCapabilities.setCapability("platformName", "Android");
//capabilities.setCapability("app", app.getAbsolutePath());
//capabilities.setCapability("appPackage","com.android.chrome");
driver = new SelendroidDriver(new URL("http://localhost:4723/wd/hub"), selendroidCapabilities);
driver.get("https:google.com");
Thread.sleep(20000);
driver.quit();
When i execute the script, its getting executed in the phone.It opens as chrome browser and open google page. No matter I have set emulator as true and created a SelendroidCapabilities with emualtor as option.
Even when i close my GenyMotion emualtor and have real android device connected and adb device command also show only one real device connected. Then too i see its getting executed in the real android device
C:\Users\Ramkumar>adb devices
List of devices attached
ZX1D63R33N device
Vice versa also same issue. if i start a real device first and GenyMotion emualtor second, then adb device command gives output as
C:\Users\Ramkumar>adb devices
List of devices attached
ZX1D63R33N device
192.168.56.101:5555 device
Having following SelendroidCapabilities is not running the script on real android device but on the GenyMotion emualtor.
SelendroidCapabilities selendroidCapabilities = SelendroidCapabilities.device(DeviceTargetPlatform.ANDROID22, "Android Emulator");
selendroidCapabilities.setEmulator(false);
Kindly suggest if i'm missing any configuration. Thanks in advance.
Regards, Ramkumar