How to push app in background and launch from same screen in Appium with selenium

前端 未结 10 889
一向
一向 2021-01-07 06:44

Is there any way to do the following process in android Automation using Appium with android driver?

Press home button from some specific screen. Put app in backgrou

10条回答
  •  北荒
    北荒 (楼主)
    2021-01-07 07:39

    public static void minimizeMaximize() {
    try {
    driver.runAppInBackground(10);
    ((AndroidDriver) driver).startActivity("appPackage", "appActivity");
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    

    You have to enter your app package name and activity name to maximize the app. For Eg:

    public static void minimizeMaximize() {
    try {
    driver.runAppInBackground(10);
    ((AndroidDriver) driver).startActivity("com.example.test", "com.example.LaunchApp");
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    

    This will definitely work.

提交回复
热议问题