我们设置DesiredCapabilities属性值得时候需要设置"appPackage"和"appActivity",如何获取到这两个值呢?
这两个值不是随便瞎写的,需要有正确的值对应,否则就会报错。
进入到 android-sdk-windowsuild-tools19.1.0 相关版本下面,用命令"aapt.exe dump badging LocationOfApp",然后就能查看到该安装包的相关信息,
有appPackage和appActivity的相关信息,把这个信息整理出来就OK了。
// To create an object of Desired Capabilities DesiredCapabilities capabilities = new DesiredCapabilities(); // Name of mobile web browser to automate. It should be an empty string, as we are automation an app capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); // Name of the OS: Android, iOS or FirefoxOS capabilities.setCapability("platformName", "Android"); // Mobile OS version – My device is running Android 4.4.2 capabilities.setCapability(CapabilityType.VERSION, "4.4.2"); // Device name: – I am using Micromax A311 capabilities.setCapability("deviceName", "Micromax A311″); // An absolute local path to the APK file capabilities.setCapability("app", app.getAbsolutePath()); // Java package of the tested Android app capabilities.setCapability("appPackage", "com.taobao.taobao"); // An activity name for the Android activity you want to run from your package. capabilities.setCapability("appActivity", "com.taobao.tao.welcome.Welcome");