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

前端 未结 10 887
一向
一向 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条回答
  • driver.runAppInBackground(Duration.ofSeconds(10));

    0 讨论(0)
  • 2021-01-07 07:26

    Here it is how it works.

    1. Code for Running the App in back ground

      ((AppiumDriver)driver).runAppInBackground(Duration.ofSeconds(10));
      
    2. Get back back to the current activity again

      ((StartsActivity)driver).currentActivity();
      
    0 讨论(0)
  • 2021-01-07 07:28

    appium_lib ruby client allows you to do this with

    background_app 5 where 5 is the number of seconds you want the app to be in background. This will automatically, resume the application in the same screen.

    0 讨论(0)
  • 2021-01-07 07:32

    You can use this snippet of code

    ((AppiumDriver)driver).runAppInBackground(Duration.ofSeconds(10));
    ((StartsActivity)driver).currentActivity();
    

    If it is not working then please update your appium with the latest version and try with the same snippet of code.

    Thanks

    0 讨论(0)
  • 2021-01-07 07:37

    Put App in background:

    ((AndroidDriver)driver).runAppInBackground(Duration.ofSeconds(20));
    

    To start App from background:

    driver.activateApp("app package name");
    
    0 讨论(0)
  • 2021-01-07 07:37

    Works for me: ((Appium 1.10, Android 8.1))

    2 options:

    1st solution:

    driver.runAppInBackground(Duration.ofMillis(300));
    

    After you close your popUp, you use this line and your app will go to background and back and you will get back the focus to your app.

    2nd solution: better one :)

    Add this line to settings:

    capability.setCapability("noReset", true);
    

    From now your app will start like normal app, without setting reset what means without pop-ups and you will not have problem with focus at all.

    I hope it will work also for you! :)

    0 讨论(0)
提交回复
热议问题