APPium自動化啟動手機應用筆記
java啟動方法
1、需要安裝JAR
2、啟動如下:
public class InitDriver {
public static AndroidDriver<AndroidElement> initDriver() throws Exception{
File app=new File("自己安裝包.apk");
DesiredCapabilities caps=new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");
caps.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Appium");
caps.setCapability(MobileCapabilityType.UDID, "127.0.0.1:62001");
caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 600);
//caps.setCapability(MobileCapabilityType.FULL_RESET, true);
caps.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "包
caps.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "簽名");
caps.setCapability(AndroidMobileCapabilityType.UNICODE_KEYBOARD, true);
caps.setCapability(AndroidMobileCapabilityType.RESET_KEYBOARD, true);
caps.setCapability(AndroidMobileCapabilityType.NO_SIGN, true);
AndroidDriver<AndroidElement> driver=new AndroidDriver<AndroidElement>(
new URL("http://127.0.0.1:4723/wd/hub"), caps);
return driver;
}
}
三、獲取報名與簽名命令:
aapt d badging Desktop\xxxxx.apk |findstr "package launchable-activity"
如:
aapt d badging Desktop\Toon-beijing-test.apk |findstr "package launchable-activity"
package: name=‘包名‘ versionCode=‘1709111541‘ versionName=‘1.8.0‘ platformBuildVersionName=‘7.1.1‘
launchable-activity: name=‘簽名‘ label=‘‘ icon=‘‘
四appium啟動方式:
appium -a 127.0.0.1 -p 4723 –U 4ca1558c --no-reset
五:DesiredCapabilities的參數配置和含義
1、本地安裝apk包的文件路徑設置,不需要安裝就不用設置
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "apps");
File app = new File(appDir, "kingyee.apk");
2、在當前session前不重置app狀態
capabilities.setCapability("noReset", true);
3、測試的web瀏覽器,如果是測app則忽略
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
4、平臺設置iOS, Android, or FirefoxOS
capabilities.setCapability("platformName", "Android");
5、設備序列號設置
capabilities.setCapability("deviceName", "Baytrail515B4E05");
6、系統版本號設置
capabilities.setCapability("platformVersion", "4.4.4");
7、避免重新簽名
capabilities.setCapability("noSign","true");
8、支持中文輸入
capabilities.setCapability("unicodeKeyboard","True");
9、重置輸入法到原有狀態
capabilities.setCapability("resetKeyboard","True");
10、設置apk的包名
capabilities.setCapability("appPackage", "com.kingyee.m");
11、設置啟動Activity
capabilities.setCapability("appActivity", "com.kingyee.m.Start");
本文出自 “知止內明” 博客,請務必保留此出處http://357712148.blog.51cto.com/6440370/1968237
APPium自動化啟動手機應用筆記