我想使用Java在selenium中执行ADB(android debug bridge)命令。稍后我需要使用我的Junit测试在AWS(亚马逊网络服务)设备场上执行脚本。怎么做 ? 请在下面找到我的Junit测试用例,在这段代码中我模拟了测试用例,我想获得应用程序的内存和CPU利用率
Text AB
答案 0 :(得分:0)
以下是我如何使用adb获取附加设备列表的示例。未显示的是adpPath变量的赋值 - 这取决于您。希望这会有所帮助。
/**
* Determine already connected physical devices or already running emulators
* @author Bill Hileman
* @return String List of running/connected devices
*/
public List<String> getRunningDevicesList() {
List<String> dev = new ArrayList<String>();
try {
String[] commandListAVDs = new String[]{adbPath, "devices"};
System.out.println("Executing command: " + adbPath + " devices");
Process process = new ProcessBuilder(commandListAVDs).start();
BufferedReader inputStream = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line = null;
while ((line = inputStream.readLine()) != null)
//ignore lines that do not contain device information
if (!(line.trim().equals("") || line.equals("List of devices attached") || line.startsWith("* daemon ")))
dev.add(line.trim());
} catch (Exception e) {
System.err.println("Unable to read device list: " + e);
e.printStackTrace();
}
System.out.println("Running Devices: " + dev.toString());
return dev;
}