标签:自动化测试 android monkey runner aapt 安装卸载
1、android aapt3、使用java来语言来调用monkeyrunner api
import com.android.chimpchat.adb.AdbBackend; import com.android.chimpchat.core.IChimpDevice; public class MonkeyTest { public static void main(String[] args) { // sdk/platform-tools has to be in PATH env variable in order to find adb IChimpDevice device = new AdbBackend().waitForConnection(); // Print Device Name System.out.println(device.getProperty("build.model")); // Take a snapshot and save to out.png device.takeSnapshot().writeToFile("out.png", null); device.dispose(); } }
package com.robot.dream.test; import com.android.chimpchat.adb.AdbBackend; import com.android.chimpchat.core.IChimpDevice; import com.sinaapp.msdxblog.apkUtil.entity.ApkInfo; import com.sinaapp.msdxblog.apkUtil.utils.ApkUtil; public class MonkeyTest { public static void main(String[] args) { String testApkPath = "D:\\apks_bak\\AndroidSensorBox.apk"; System.out.println("start"); IChimpDevice device = new AdbBackend().waitForConnection(); System.out.println("monkey test connected"); device.installPackage(testApkPath); System.out.println("install package success"); try { Thread.sleep(3000); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { ApkInfo apkInfo = new ApkUtil().getApkInfo(testApkPath); String pkgName = apkInfo.getPackageName(); System.out.println("package name is "+pkgName); device.removePackage(pkgName); System.out.println("remove package success"); } catch (Exception e) { e.printStackTrace(); } // Print Device Name System.out.println(device.getProperty("build.model")); // Take a snapshot and save to out.png device.takeSnapshot().writeToFile("D:\\out1.png", "PNG"); device.dispose(); } }
标签:自动化测试 android monkey runner aapt 安装卸载
原文地址:http://blog.csdn.net/vshuang/article/details/39502405