Managing your mobile device capabilities need so much effort in case you change your device frequently. During the test, there are mandatory capabilities that you need to manage like “Platform Name”, “Device Version”, “Device Name” or “UDID” information.
You need to run ADB command to extract those kinds of data or you need to manually find them out.
You need to run ADB command to extract those kinds of data or you need to manually find them out.
Bahadır Üstün, has recently developed a library to fetch information from devices connected to your computer. It fetches any information that can be captured from your IOS or Android device.
Here is the library GitHub Link: https://github.com/Testinium/MobileDeviceInfo
You can add your project as a maven dependency.

You have to add our repository to your pom.xml because it hasn’t released to Maven Central repositories.

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PLATFORM, device.getDeviceProductName());
capabilities.setCapability("platformName", device.getDeviceProductName());
capabilities.setCapability(CapabilityType.VERSION, device.getProductVersion());
capabilities.setCapability("deviceName", device.getModelNumber());
capabilities.setCapability("udid", device.getUniqueDeviceID());
capabilities.setCapability("app", "#Your App File#");
driver = new RemoteWebDriver(new URL(URL), capabilities);