question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android app can not be brought to foreground on appium2

See original GitHub issue

The problem

Android app can not be brought to foreground on appium2 from background, which works on appium1.

Environment

  • Appium version (or git revision) that exhibits the issue: v2.0.0-beta.43
  • Last Appium version that did not exhibit the issue (if applicable): v1.23
  • Desktop OS/version used to run Appium: MacOS Monterey 12.5.1 M1
  • Node.js version (unless using Appium.app|exe): v18.8.0
  • Npm or Yarn package manager:
  • Mobile platform/version under test:
  • Real device or emulator/simulator: Redmi Note8 (Android 9) and Pixel 2 (Android 11)
  • Appium CLI or Appium.app|exe:

Details

We tried to launch and bring the Android Settings app to foreground, but it failed if the app was already in the background. Another wrong app will be started and brought to foreground.

Instead, if we manually killed the Settings app before execution. It will be brought to foreground, even if there’s another app already on the foreground.

By the way, right now it seems the shouldTerminateApp does not work on Anroid, just leaving the app as is after the test run. Is there another capability to handle this?

Kindly please advise, thanks a lot in advance!

Link to Appium logs

https://gist.github.com/bswhb/6c4b5c05d1acaf3f718b577725d58588

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
StephanB75commented, Sep 7, 2022

Do you use driver.activateApp(“com.android.settings”); and driver.terminateApp(“com.android.settings”);

This work for me with appium 2.0 ( but only used in emulators)

0reactions
bswhbcommented, Sep 8, 2022

thanks for the info and issue closed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bring app back to foreground from code doesn't work on ...
I have found the solution so I'll post it here if someone needs it. The code I use to put the application back...
Read more >
Restrictions on starting activities from the background
Note: For the purposes of starting activities, an app running a foreground service is still considered to be "in the background".
Read more >
Getting Started with Appium 2.0: Overview of the Core New ...
Appium is an open source test automation framework for use with native, hybrid and mobile web apps. It drives iOS, Android, and Windows...
Read more >
appium/appium - Gitter
while i cannot see the element until i do not scroll the scrollable element that is the ... Does anyone know how to...
Read more >
Android: bring application into foreground after backgrounding
To background, I'm sending the home button using mobile: keyevent 3, but to bring the app back I'm not sure about the best...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found