Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[💡 Feature]: add new mobile custom command to relaunch the app #12626

Open
1 task done
wswebcreation opened this issue Apr 4, 2024 · 6 comments
Open
1 task done
Assignees
Labels
Idea 💡 A new feature idea

Comments

@wswebcreation
Copy link
Member

Is your feature request related to a problem?

The launchApp command is deprecated and should be replaced with an alternative

Describe the solution you'd like.

This is a sample we use for our native demo app. We need to check the bundleId/packageName of the current app under test.

async function relaunchApp() {
  const PACKAGE_NAME = 'com.wdiodemoapp'
  const BUNDLE_ID = 'org.reactjs.native.example.wdiodemoapp'
  const appIdentifier = browser.isAndroid ? { 'appId': PACKAGE_NAME } : { 'bundleId': BUNDLE_ID }
  const terminateCommand = 'mobile: terminateApp'
  const launchCommand = `mobile: ${driver.isAndroid ? 'activateApp' : 'launchApp'}`

  await browser.execute(terminateCommand, appIdentifier)
  await browser.execute(launchCommand, appIdentifier)
}

Describe alternatives you've considered.

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@wswebcreation wswebcreation added Needs Triaging ⏳ No one has looked into the issue yet Idea 💡 A new feature idea labels Apr 4, 2024
@wswebcreation wswebcreation removed the Needs Triaging ⏳ No one has looked into the issue yet label Apr 4, 2024
@wswebcreation wswebcreation self-assigned this Apr 4, 2024
@christian-bromann
Copy link
Member

It would be actually nice if this could be a native Appium command. I wonder what Appium does when calling the refresh WebDriver command? We could just run above code in the Appium server.

@jlipps what do you think?

@jlipps
Copy link
Contributor

jlipps commented Apr 4, 2024

I guess there's no reason it couldn't be in Appium itself. What do you think @mykola-mokhnach?

@mykola-mokhnach
Copy link

mykola-mokhnach commented Apr 4, 2024

I guess there's no reason it couldn't be in Appium itself. What do you think @mykola-mokhnach?

I don't see how such API could look like. In Android and iOS extensions to run apps work differently, not saying about other drivers.

For example, in order to restart an iOS app one could perform mobile: launchApp and xctest automatically terminates it if it is already running.
In Android for the mobile: startActivity API one must set stop arg to true in order for the activity to be restarted upon launch.

@christian-bromann
Copy link
Member

I don't see how such API could look like.

Ideally it would be great if we could the operation of restarting an app within the refresh WebDriver command (/session/{session id}/refresh). To simplify this, it would require the xcuitest and uiautomator2 driver to keep the information which app was or is currently opened. Can you confirm if these drivers are capable to do that? Maybe Appium could call getCurrentActivity for example in Android as part of the execution.

@mykola-mokhnach
Copy link

Unfortunately it's not so simple. The current activity might not be launchable. Also, we don't know what/if we need to apply any additional arguments or environment variables on startup.

@christian-bromann
Copy link
Member

The current activity might not be launchable.

In this case the refresh command should/would fail.

Also, we don't know what/if we need to apply any additional arguments or environment variables on startup.

Is there a way to pull these information before we shut down the app and use them when starting the app again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Idea 💡 A new feature idea
Projects
None yet
Development

No branches or pull requests

4 participants