2016-05-12 43 views

回答

3

iOS和Android的支持以下方法:

(AppiumDriver)driver.runAppInBackground(10);//put app in background for 10 seconds 
(AppiumDriver)driver.launchApp();//launch the app again 

希望它能幫助!

+0

driver.runAppInBackground(10);使應用程序在後臺運行10秒鐘,並在主屏幕10秒後啓動。但我想從我進入背景的同一屏幕啓動它。 –

+2

爲此,你必須在下面的例子中使用不重置爲真的功能:capabilities.setCapability(「 - no-reset」,true); – noor

+0

它要求我添加演員。如果我添加一個它不起作用。 – vaibhavcool20

3
  • 試圖把重點放在你當前活動:

    (AppiumDriver)driver.runAppInBackground(10); (AppiumDriver)driver.currentActivity();

  • 嘗試啓動你在同一個活動:

    (AppiumDriver)driver.runAppInBackground(10);
    (AppiumDriver)driver.startActivity("appPackage","com.example.android.apis", null, null);

0

driver.runAppInBackground(Duration.ofSeconds(10));

0

appium_lib紅寶石客戶端,可以與

background_app 5其中5是你想要的應用程序是在後臺的秒數做到這一點。這將自動在同一屏幕上恢復應用程序。