獲取設(shè)備號(hào)
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
* 通過(guò)執(zhí)行dos命令獲取結(jié)果
*
* @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;
}
/**
* 獲取手機(jī)版本
*
* @return
*/
public static String getMobileModel() {
/**
* 獲取手機(jī)版本
*/
String mobileModel = "adb shell getprop ro.product.model";
String s = OperationalCmd.execReturnAndWait(mobileModel);
return s;
}
/**
* 獲取手機(jī)系統(tǒng)版本
* 版本號(hào)
*
* @return
*/
public static String getVersionNameInfo() {
/**
* 版本號(hào)
*/
String versionName = "adb shell dumpsys package com.jingdong.th.app | findstr versionName";
/**
* 獲取手機(jī)系統(tǒng)版本
*/
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;
}
新聞標(biāo)題:appium自動(dòng)化報(bào)表自定義并且截圖-補(bǔ)充
文章出自:
http://weahome.cn/article/jgodph.html