appium自动化测试,startActivity实现不同app之间切换(包括app内部页面切换和不同app跳转)

public static void main(String[] args) throws MalformedURLException {

        DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
        desiredCapabilities.setCapability("appium:platformName", "Android");
        desiredCapabilities.setCapability("appium:platformVersion", "10");
        desiredCapabilities.setCapability("appium:deviceName", "66J5T18C0000000000000000");
        //app的包名
        desiredCapabilities.setCapability("appium:appPackage", "com.hwawsbao.hbstockwwhbarning");
        //app的启动入口
        desiredCapabilities.setCapability("appium:appActivity", "com.hwawsbao.hbstockwwhbarning.splash.HBSplashActivity");
        //解决输入不能自动输入的问题.添加一个自动化引擎
        desiredCapabilities.setCapability("automationName", "uiautomator2");
        //不用用每次都清理缓存启动
        desiredCapabilities.setCapability("noReset", "true");

        //创建驱动
        //appium的通讯地址
        //配置对象
        androidDriver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), desiredCapabilities);


    }
    /**
     * startActivity实现不同app之间切换
     */
    public void startActivity() {
        //1.页面跳转。---app内部页面跳转
        /*Activity activity = new Activity("com.hwabao.hbstockwarning", "com.hwabao.hbstockwarning.splash.HBSplashActivity");
        androidDriver.startActivity(activity);*/
        //2app相互跳转,比如由app1跳转到app2去(这里智能跳转到启动入口)
        Activity activity1 = new Activity("com.android.browser", "com.android.browser.BrowserActivity");
        androidDriver.startActivity(activity1);
    }

你可能感兴趣的:(性能压测及自动化测试,appium,android,java)