Appium 如何创建多个 session,并且可以随意切换?主要为了测两个 App, 但是 App 之间有互动。
我想的笨办法:
创建一个 session 打开一个 app,测试结束后退出,重新创建 session...有没有比较智能的办法多个 session,可以随时切换?

    @Test
    public void testtest() throws InterruptedException {

        CommonMethods.openManager();
        System.out.println("...........................Open Manager!!!!");
        CommonMethods.tearDown();
        CommonMethods.openMember();

        System.out.println("......................Open Member!!!!");        
        CommonMethods.tearDown();
    }


public class CommonMethods {

    private static AppiumDriver driver;

    public static void openManager() {

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName", "Android");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("platformVersion", "4.4");
        capabilities.setCapability("appPackage", "net.everbridge");
        capabilities.setCapability("appActivity", ".ui.SplashUI");
        try {
            driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),
                    capabilities);
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


    }


    public static void openMember() {

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName", "Android");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("platformVersion", "4.4");
        capabilities.setCapability("appPackage", "com.everbridge.mobile.iv.recipient");
        capabilities.setCapability("appActivity", ".SplashActivity");
        try {
            driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),
                    capabilities);
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    public static void tearDown() {
        driver.quit();
    }
}


↙↙↙阅读原文可查看相关链接,并与作者交流