Hi,
Thanks for your reply. I was trying to minimize the command line commands to run the test. So I set capabilities in test script class. (I use Android studio to write test scripts)
I found a work around for this.
I used try/catch to see if real device is connected.
private static RemoteWebDriver getWebDriver(DesiredCapabilities capabilities) throws MalformedURLException {
return new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
try {
driver = getWebDriver(getDeviceCapabilities());
} catch (Exception e) {
driver = getWebDriver(getSimulatorCapabilities());
}
And it is working perfectly fine!