zoukankan      html  css  js  c++  java
  • 一台机器同时运行多个appium实例

    测试需要同时在多个android设备上运行,就需要启动多个appium

    第一台是运行微信:

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
    capabilities.setCapability("deviceName", "c4072fb8090b");
    capabilities.setCapability("udid", "c4072fb8090b");
    //设置每次运行不重新启动被测试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();
    }

    第二台是测试机配置:

    File classpathRoot = new File(System.getProperty("user.dir"));
    File appDir = new File(classpathRoot, "app");
    // 微信程序
    File app = new File(appDir, "xxxx_xxx_test2.apk");

    //设置自动化相关参数
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
    capabilities.setCapability("deviceName", "192.168.56.101:5555");
    capabilities.setCapability("udid", "192.168.56.101:5555");
    //设置每次运行不重新启动被测试app
    capabilities.setCapability("noReset","true");
    capabilities.setCapability("fullReset","false");
    //设置安卓系统版本
    capabilities.setCapability("platformVersion", "4.4");
    capabilities.setCapability("platformName", "Android");
    // session 延迟时间
    capabilities.setCapability("newCommandTimeout",24000);
    capabilities.setCapability("device", "selendroid");
    capabilities.setCapability("app", app.getAbsolutePath());
    String abc = app.getAbsolutePath();
    //设置app的主包名和主类名 微信程序包名和activity 名
    capabilities.setCapability("appPackage", "com.xx.xx");
    capabilities.setCapability("appActivity", "com.xx.xx.EntryActivity");
    //启动
    try {
    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
    } catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    主要是要加一条配置:capabilities.setCapability("udid", "192.168.56.101:5555");

    启动多个appium ,设置不同的端口号,就可以同时运行多个appium driver了。

  • 相关阅读:
    centos7.6 安装与配置 MongoDB yum方式
    MongoDB 介绍
    centos 关闭selinux
    前端 HTML标签属性
    前端 HTML 标签嵌套规则
    前端 HTML 标签分类
    前端 HTML body标签相关内容 常用标签 表单标签 form里面的 input标签介绍
    前端 HTML body标签相关内容 常用标签 表单标签 form 表单控件分类
    前端 HTML form表单标签 select标签 option 下拉框
    POJ 1426
  • 原文地址:https://www.cnblogs.com/testway/p/5257683.html
Copyright © 2011-2022 走看看