macaca icon indicating copy to clipboard operation
macaca copied to clipboard

macaca有提供接口去安装和卸载应用的吗?

Open wynanwong opened this issue 9 years ago • 1 comments

macaca有提供接口去安装和卸载应用的吗?我看了一遍API文档,没看到相应的接口。

wynanwong avatar May 03 '17 08:05 wynanwong

https://macacajs.github.io/zh/java 请看这段demo 在 setUp() 中 ` public void setUp() throws Exception {

    JSONObject porps = new JSONObject();
    porps.put("autoAcceptAlerts", true);
    porps.put("javascriptEnabled", true);

  //porps.put("deviceName", "iPhone 6s"); //ios 需要指定设备名
    porps.put("platformName", "Android"); // Android or ios
    porps.put("version", ""); //系统版本 ios需要指定系统版本
    porps.put("reuse", 3);
    /* 0: Launch the simulator and install the app. 
    1 (default): Uninstall the app and reinstall the app. 
    2: Only reinstall the app. 
    3: Keep the simulator and app after testing.*/
    
    porps.put("udid", udid);// custom devices udid 
    
  //porps.put("udid", "your udid"); //ios udid唯一设备识别符
  //porps.put("bundleId", "zx.ios-app-bootstrap"); //ios bundleId App应用标识符

  //porps.put("app", "D:\\Install\\apk\\acp_android_v4_1_7-233611.apk");
    porps.put("package", "com*。*");//appPackage   
    porps.put("activity", ".BootUI");//appActivity 

		
	JSONObject desiredCapabilities = new JSONObject();
	desiredCapabilities.put("host", "127.0.0.1"); // custom server host 
	desiredCapabilities.put("port", Integer.parseInt(port)); // custom server port 
	desiredCapabilities.put("desiredCapabilities", porps);
	
      if(port.equals("3456"))
        {
            Thread.sleep(1000);
        }
	driver.initDriver(desiredCapabilities);

}`

porps.put("app", "D:\Install\apk\*.apk"); 这一段这么写 win环境下 即可自动安装你所测apk

Archer456 avatar May 05 '17 06:05 Archer456