9

I am able to get the device android version using

driver.getCapabilities().getCapability("platformVersion");

Simillarly how I will get device name and version of app. I tried with following but no use

driver.getCapabilities().getCapability("deviceName");
driver.getCapabilities().getCapability("appVersion");
Venkatesh G
  • 8,466
  • 4
  • 13
  • 22

3 Answers3

11

Using Adb

To get Device Name

adb.exe -s " +deviceID+ " shell getprop ro.product.model

To get Device OS Version

adb.exe -s " +deviceID+ " shell getprop ro.build.version.release

To get App Version

adb -s " +deviceID+ " shell dumpsys package yourPackageName | grep versionName
Venkatesh G
  • 8,466
  • 4
  • 13
  • 22
9
driver.getCapabilities().getCapability("deviceName").toString();
driver.getCapabilities().getCapability("CapabilityType.VERSION").toString();

This will return you the device name and OS version as set in desired capabilities. If you want to get device information before creating driver or at run time (to check correct information of connected device) then you have to use the following to get device OS version. (adb for android and instruments for iOS)

For android -

adb -s " + deviceID + " shell getprop ro.build.version.release

For iOS -

instruments -s devices

Store the output from above command in String array and retrieve required information.

Suman
  • 436
  • 4
  • 10
  • 1
    Great..! Do you have any Idea to get version of current running app – Venkatesh G Aug 19 '16 at 10:25
  • Do you have any "About" or Settings option in the app, if yes then you can check app version from these options. Else, Open Android Settings, navigate to your app, read version. – Suman Aug 19 '16 at 11:43
  • This is helpful but doesn't really answer the original question. Is there a way to use `instruments` to query (version) information about an app on a connected device? `instruments -s devices` just displays the OS version. – martin Nov 19 '18 at 06:22
0

Use this:

driver.getCapabilities().getCapability("deviceModel").toString()
Nick is tired
  • 6,860
  • 20
  • 39
  • 51
Suresh Sharma
  • 186
  • 1
  • 5
  • 23