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

Need altenate method for AppiumDriver.launchApp() in new java client version 8.x #1871

Open
dipikachowdhary07 opened this issue Mar 21, 2023 · 7 comments

Comments

@dipikachowdhary07
Copy link

I am upgrading my current project from appium.java-client.version 6.1.0 to 8.1.1
My previous code base was using AppiumDriver.launchApp() method to go to home screen, but I couldnot find any alternate method in version 8.1.1
I also went through appium/appium#15807 but couldnot find any relevant information. Can anyone please help on this?

@mykola-mokhnach mykola-mokhnach transferred this issue from appium/appium Mar 21, 2023
@diebold2000
Copy link

I also have the same question. I have a suite where each test should start from Login screen (Home). So basically what I do in io.appium:java-client:7.6.0 is to call in @BeforeMethod (Test) TestNG:

  • driver.terminateApp(appBundleId)
  • driver.launchApp()
    This eventually makes fast app restart and back user to Login screen. For both iOS and Android devices.
    Moreover test only knows application bundle ID (package in Android). Application is pre-installed by CI tool before actually test begins.

@diebold2000
Copy link

ok. It seems there is a workaround (Kotlin):

(driver as InteractsWithApps).activateApp(appBundleId)
(driver as InteractsWithApps).terminateApp(appBundleId)

@deepakarorawins
Copy link

deepakarorawins commented Sep 25, 2023

@diebold2000 @dipikachowdhary07 @mykola-mokhnach any update on the same question (how to make fast app restart and back user to Login screen / Home screen in the absence of driver.launchApp())

@diebold2000
Copy link

Hello @deepakarorawins with client 8.3.0 and server 2.0.1 the following statements work perfectly for me (Kotlin):

fun restartMobileApplication() { if (driver != null) { (driver as InteractsWithApps).terminateApp(Configuration.appBundleId) (driver as InteractsWithApps).activateApp(Configuration.appBundleId) } }

This code is executed under @BeforeMethod and gets user to Login screen every time.

@deepakarorawins
Copy link

Hello @deepakarorawins with client 8.3.0 and server 2.0.1 the following statements work perfectly for me (Kotlin):

fun restartMobileApplication() { if (driver != null) { (driver as InteractsWithApps).terminateApp(Configuration.appBundleId) (driver as InteractsWithApps).activateApp(Configuration.appBundleId) } }

This code is executed under @BeforeMethod and gets user to Login screen every time.

Thanks @diebold2000, however it is not working for me using java, earlier we use to see logged out state after using launchApp() method, but now it keeps us logged in. So all our test which are expected to start with login, are failing because app is already logged in.

@mykola-mokhnach any suggestion from your side please?

@mykola-mokhnach
Copy link
Contributor

Check appium/appium#19203 (comment)

@deepakarorawins
Copy link

For iOS, uninstall the app, then install it again does the same thing. (launchApp endpoint did it the same) This is not Android, but for Android, you could use https://github.com/appium/appium-uiautomator2-driver?tab=readme-ov-file#mobile-clearapp

Thank you @mykola-mokhnach

Check appium/appium#19203 (comment)

Thank you @mykola-mokhnach for the help, however my observation is that removeApp then installApp and then launchApp/ActivateApp takes more time in comparison to just old launchApp() method, is this expected?

For our iOS app Old launchApp() is taking: 21 seconds approximately.
getDriver().launchApp();

For our iOS app New removeApp-->installApp-->launchApp is taking 28 seconds approximately.
String bundleId = getDriver().getCapabilities().getCapability("bundleId").toString();
String app = getDriver().getCapabilities().getCapability("app").toString();
Map<String, Object> args = new HashMap<>();
args.put("bundleId", bundleId);
args.put("app", app);
getDriver().executeScript("mobile: removeApp", args);
getDriver().executeScript("mobile: installApp", args);
getDriver().executeScript("mobile: launchApp", args);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants