How to get Device name and App Version using Appium Driver

一世执手 提交于 2020-04-10 03:21:41

问题


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

回答1:


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



回答2:


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.




回答3:


Use this:

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


来源:https://stackoverflow.com/questions/39032883/how-to-get-device-name-and-app-version-using-appium-driver

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!