Appium同时运行多个设备

为了提高测试效率,测试需要同时在多个android设备上运行,就需要启动多个appium。

启动appium时,为每个设备设置不同的端口号,并为driver设置该设备的udid。见如下实例,关键是红色部分

DesiredCapabilities capabilities = new DesiredCapabilities(); 
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "minote");
capabilities.setCapability("udid", "AQPRBMWGJN45CMR8");
//设置每次运行不重新启动被测试app
capabilities.setCapability("noReset","true");
capabilities.setCapability("fullReset","false"); 
//设置安卓系统版本
capabilities.setCapability("platformVersion", "4.4"); 
capabilities.setCapability("platformName", "Android"); 
capabilities.setCapability("device", "selendroid"); 
capabilities.setCapability("app", app.getAbsolutePath()); 
String abc = app.getAbsolutePath();
//设置app的主包名和主类名 微信程序包名和activity 名 
capabilities.setCapability("appPackage", "com.tencent.mm");
capabilities.setCapability("appActivity", "com.tencent.mm.ui.LauncherUI"); 
//启动
try {
driver = new AndroidDriver(new URL("http://127.0.0.1:4725/wd/hub"),capabilities);
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

转载于:https://www.cnblogs.com/Lihao2013/p/6290661.html

你可能感兴趣的:(Appium同时运行多个设备)