Appium學習筆記1_獲取到APK安裝包的Package以及Activity屬性值

tao先生發表於2015-09-11

我們設定DesiredCapabilities屬性值得時候需要設定"appPackage"和"appActivity",如何獲取到這兩個值呢?

這兩個值不是隨便瞎寫的,需要有正確的值對應,否則就會報錯。

進入到 android-sdk-windows\build-tools\19.1.0 相關版本下面,用命令"aapt.exe dump badging LocationOfApp",然後就能檢視到該安裝包的相關資訊,

appPackageappActivity的相關資訊,把這個資訊整理出來就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");

  

 

相關文章