java 如何使用 Appium 驱动程序获取设备名称和应用程序版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39032883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get Device name and App Version using Appium Driver
提问by Venkatesh G
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");
回答by Venkatesh G
Using Adb
使用亚行
To get Device Name
获取设备名称
adb.exe -s " +deviceID+ " shell getprop ro.product.model
adb.exe -s " +deviceID+ " shell getprop ro.product.model
To get Device OS Version
获取设备操作系统版本
adb.exe -s " +deviceID+ " shell getprop ro.build.version.release
adb.exe -s " +deviceID+ " shell getprop ro.build.version.release
To get App Version
获取应用版本
adb -s " +deviceID+ " shell dumpsys package yourPackageName | grep versionName
回答by Suman
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)
这将返回您在所需功能中设置的设备名称和操作系统版本。如果您想在创建驱动程序之前或在运行时获取设备信息(以检查连接设备的正确信息),那么您必须使用以下内容来获取设备操作系统版本。(adb for android 和instruments for iOS)
For android -
对于安卓 -
adb -s " + deviceID + " shell getprop ro.build.version.release
For iOS -
对于 iOS -
instruments -s devices
Store the output from above command in String array and retrieve required information.
将上述命令的输出存储在字符串数组中并检索所需的信息。
回答by Suresh Sharma
Use this:
用这个:
driver.getCapabilities().getCapability("deviceModel").toString()