How to invoke Recent apps activity and launch app from recent app list by using appium?

How to invoke Recent apps activity and launch app from recent app list by using appium?

1 Like

driver.pressKey(187); --> driver.findElements(“App Name”).click();

1 Like

Thanks for your reply.

Still I’m facing the problems…find below code for your reference.

AppiumDriver driver;
AndroidDriver drAndroid;

public void recentApp() {

        // driver.pressKey(187); //getting error after that created " drAndroid"

          drAndroid.pressKeyCode(187);
         
          driver.findElements("Whatsapp").click(); // I'm not able to use driver.findElements

    }

drAndroid.pressKeyCode(187);
drAndroid.findElement(“Whatsapp”).click();

Try above… BTW why do u require two driver instances?

First instance is not working. That’s why created second instance as AndoridDrvier(will delete AppiumDriver).

Question 1 : ----- not able to use Home package
capabilities.setCapability(“appPackage”, “com.android.systemui”);
capabilities.setCapability(“appActivity”, “com.android.systemui.recents.RecentsActivity”);

@BeforeClass Setup
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Permission to start activity denied.) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 4.57 seconds
Qaestion 2 -------- if i use launcer activity gettting ‘null’ exception…plz refer below code

capabilities.setCapability(“appPackage”, “com.android.launcher”);
capabilities.setCapability(“appActivity”, “com.android.launcher2.Launcher”);

Thread.sleep(5000);

         drAndroid.findElement(By.id("com.android.systemui:id/task_view_bar")).click();

recent app list is displaying for a while n getting Exception is - ’ null ’

Priyank - it’s working fine and find below code for all reference…

Thanks for your suggestion.

AndroidDriver driver;

capabilities.setCapability(“appPackage”, “com.android.launcher”);
capabilities.setCapability(“appActivity”, “com.android.launcher2.Launcher”);

driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

Thread.sleep(5000);

driver.pressKeyCode(187);
driver.findElement(By.name(“Messaging”)).click();

Hi Rahul,

I tried out the above code. But getting back:
org.openqa.selenium.InvalidSelectorException: Locator Strategy ‘name’ is not supported for this session

Any idea on this?

Byname is depreciated and also, how to get app name ?

   driver.pressKey(new KeyEvent(AndroidKey.APP_SWITCH));

   driver.pressKey(new KeyEvent(AndroidKey.DPAD_DOWN));
   driver.pressKey(new KeyEvent(AndroidKey.DPAD_DOWN));     

   driver.pressKey(new KeyEvent(AndroidKey.ENTER));
1 Like