How to terminate android app using Katalon Studio?

Hey Guys, please teach me to terminate android app using Katalon Studio, if I using keyword close application, after application relaunched in will redirect to last opened location, I need to make it redirect to the first screen after relaunched, Thank you in advance Guys

Hi @teguh.hariyadi,

To get a mobile app to reset after your test, it’s actually controlled when you start the application by providing true as the second parameter. The next time the app starts, it will be a fresh version:

Mobile.startApplication('C:\\Users\\admin\\androidfile.apk', true)

See this document for more about Mobile.startApplication:

Hope this helps,

Chris

2 Likes

Hello @Chris_Trevarthen Thanks for your answer.
So if we use application start keyword, we need to use start application keyword again in the next test case right(in order to run in test suite)? because it will uninstall the app after the app closed. Is it posible to make next start app redirect to first screen (home) instead of start the app as fresh version?, because if start the application as fresh version there will be several pop-up appears after launch the app.

Hi @teguh.hariyadi,

If you’re using a test suite, then I recommend starting the app in the first test of the suite and not closing it until the last test of the suite. In fact, you may want to create a test specifically for starting up and stopping the app so those functions don’t get mixed in with other test logic.

As for navigating through the app, you could structure your tests a few ways:

  1. Each test “cleans” up after itself. That is to say, at the end of each test, you return to the home screen, log the user out, etc.
  2. Each test puts itself into the state that it needs. So at the beginning of each individual test, you navigate to the screen that you need, assuming nothing about the current screen the app is showing. This can be flexible to allow reordering or disabling tests. It does require handling failures a little differently - you’ll need to make more checks optional, since you might not start the test on the same screen each time.
  3. Create “utility” tests that reset the app to the conditions you need. For example, if you need to make sure you have a logged in user on the home screen, create a test that does only that. You can then insert that test multiple times in your suite to get the app to the point you need for each test.

Hope this helps,
Chris

1 Like

Hello @Chris_Trevarthen Thanks for your reply.

I have used the navigation structure as you suggested, but my real problem is when running such a test, sometimes the buttons in the application are not pressed properly, this causes the test case to not return home at the end of the step, and this will result the test case after that also failed to execute properly. Do you have any suggestions regarding this problem?

Warm Regards,
Teguh

Hi @teguh.hariyadi,

A couple of things come to mind:

  1. If the buttons aren’t pressed correctly, then that does seem like an error and it’s good that the test caught it :slight_smile: However, I can see that being annoying if you’re trying to test later parts of the app but the first tests fail.

  2. Making sure each test sets itself up for the right conditions is more robust than relying on the tests beforehand to succeed. This is where you would start your test with something like tapping navigation buttons to get back to the home screen. You could also build a test whose job is specifically to get back to the home screen, no matter where you are in the app. You could call that test between each test of your suite to make sure the next test is set up correctly.

Hope this helps,

Chris

1 Like

Hi @Chris_Trevarthen.
I will try your suggestion :smile: :+1:
Thanks you

Regards.
Teguh