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);
    }
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐