appium自動化レポートカスタマイズおよびスクリーンショット-補足
2660 ワード
デバイス番号の取得 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;
}
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;
}