简体   繁体   中英

How to get Device name and App Version using Appium Driver

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");
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.

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

用这个:

driver.getCapabilities().getCapability("deviceModel").toString()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM