How to find device info programmatically

I am connecting real devices to my system and want to read device UDID OS , OS versions programatically for IOS. Appreciate any help on this
Our Framework Appium Java , Junit.

We do it by making a system call to instruments -s devices and then iterating through the list of devices until we find the one we want. Then it’s just a matter of string manipulation to pull out the uuid and other information.

We find it very important to keep simulators down to a minimum, and to make sure device names are unique. Often we will name a device with the iOS version and internal asset tag to make sure we are getting the device we want. So something like: iPhone6_12.1_<Asset_Tag>. Using no spaces in the name can also help a lot.

Thanks @wreed will try that approach. am also trying to set ANDROID desired capabilities tryin to capture device version, os from adb shell commands . while executing shell commands in cmd
“adb shell getprop ro.build.version.release” it is giving me value. But programmatically am unable to below is the code :

  java.lang.Runtime rt = java.lang.Runtime.getRuntime();
	java.lang.Process p = rt.exec("adb.exe shell getprop ro.boot.serialno"); 
	java.io.InputStream is = p.getInputStream();
	java.io.BufferedReader reader = new java.io.BufferedReader(new InputStreamReader(is));
	
	String s= (reader.readLine());

		while ((s = reader.readLine()) != null) {
		System.out.println(s);
	
		}
		is.close();

Our code is all in Ruby, so my code probably won’t help, but we use adb devices and then parse the needed info from the return.

I did find an example of someone using ProcessBuilder to run adb commands. Probably worth a look:

better:

adb devices -l

look at examples: Appium Pro: Running arbitrary ADB commands via Appium

1 Like

thanks @Aleksei To find platform version I am stuck calling adb shell commands. is there any way