获取设备号
public static String formatDate(long date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return formatter.format(date);
}
/**
* get result of command, after execute dos command
* 通过执行dos命令获取结果
*
* @param :dos command,String
* @return List
*/
public static List execCmdConsole(String cmdString) {
List dosRes = new ArrayList();
Process process = null;
try {
LogUtil.info(cmdString);
if (osName.toLowerCase().contains("mac")) {
String[] command = {"/bin/sh", "-c", cmdString};
process = Runtime.getRuntime().exec(command);
} else if (osName.toLowerCase().contains("win")) {
process = Runtime.getRuntime().exec("cmd /c " + cmdString);
}
InputStream in = process.getInputStream();
BufferedReader inr = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = inr.readLine()) != null) {
dosRes.add(line);
}
try {
process.waitFor();
process.destroy();
} catch (InterruptedException e) {
e.printStackTrace();
}
log.debug("get result of command after execute dos command " + cmdString + " Succeed ");
} catch (IOException e) {
log.error("get result of command after execute dos command " + cmdString + " Failure", e);
}
return dosRes;
}
/**
* 获取手机版本
*
* @return
*/
public static String getMobileModel() {
/**
* 获取手机版本
*/
String mobileModel = "adb shell getprop ro.product.model";
String s = OperationalCmd.execReturnAndWait(mobileModel);
return s;
}
/**
* 获取手机系统版本
* 版本号
*
* @return
*/
public static String getVersionNameInfo() {
/**
* 版本号
*/
String versionName = "adb shell dumpsys package com.jingdong.th.app | findstr versionName";
/**
* 获取手机系统版本
*/
String versionRelease = "adb shell getprop ro.build.version.release";
List devList = OperationalCmd.execCmdConsole(versionName);
String s = devList.get(0).split("=")[1] + "/Android:" + OperationalCmd.execReturnAndWait(versionRelease);
return s;
}
新闻名称:appium自动化报表自定义并且截图-补充
文章网址:
http://cdweb.net/article/jgodph.html