习惯性伸手党区 appium+Java 如何处理多个手机同时运行执行 case

access · 2015年06月19日 · 最后由 Monkey 回复于 2015年06月20日 · 2702 次阅读

最近在写 Java appium case,现在大部分自动化脚本都很稳定了,但是在跑脚本过程中花费时间较长,大概跑 5 个多小时,知道 appiium 同时支持多个手机,自己也想过用多线程,在网上搜了半天没有发现如何做多个手机同时运行,所以就写了这个帖子,希望大家帮忙解决一下
如下是 启动代码:

public static AppiumDriver driver;
    public static String configXYPath = "src/config/configXY.xml";
    public static String runSettingPath = "src/config/runSetting.xml";

    @BeforeSuite
    public static void SetUp() {

        File classpathRoot = new File(System.getProperty("user.dir"));
        File appDir = new File(classpathRoot, "apps");
        File app = new File(appDir, "zm4.4.0.apk");
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("deviceName", "4df04b421d093033");
        capabilities.setCapability("platformVersion", "4.3");
        capabilities.setCapability("app", app.getAbsolutePath());
        capabilities.setCapability("appPackage", "com.gaiay.mobilecard");
        capabilities.setCapability("appActivity",
                "com.gaiay.businesscard.StartPage");
        capabilities.setCapability("unicodeKeyboard", "True");
        capabilities.setCapability("resetKeyboard", "True");
        try {
            driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
                    capabilities);
            Thread.sleep(8000);
            GetData.Screenshot(driver, "C:\\photo\\", "登陆第一页");

            for (int i = 0; i < 3; i++) {
                int Sx = GetData.GetXmlConfig(
                        GetData.GetXmlSetting("phoneType"), "start", "startX");
                int Sy = GetData.GetXmlConfig(
                        GetData.GetXmlSetting("phoneType"), "start", "startY");
                int Ex = GetData.GetXmlConfig(
                        GetData.GetXmlSetting("phoneType"), "start", "endX");
                int Ey = GetData.GetXmlConfig(
                        GetData.GetXmlSetting("phoneType"), "start", "endY");
                driver.swipe(Sx, Sy, Ex, Ey, 2000);
                Thread.sleep(1000);
            }

            Login.definedEle.GYWaitFindEle(driver,
                    By.id("com.gaiay.mobilecard:id/mTvOpen")).click();
            Thread.sleep(5000);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
共收到 5 条回复 时间 点赞

论坛里已经有解决方案了。

请添加头像!

请添加头像!

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册