How to use same Login session to run multiple Mobile Tests

I want to automate Internet Banking Mobile Application. For example I have 5 Testcases

  1. Login Test
  2. Check Balance Test
  3. Fund Transfer Test
  4. Utility Payment Test
  5. Logout Test.

Here I want to login once and execute the 3 tests and at last I want to run logout. How can I do that for Mobile Application?

Have you looked at creating a Test Suite of the Test Cases.

Here my question is like do we need to add startApplication step in every testcase? If I add that then my logged in session might expired so I may need to login again

You may have to change your Test Cases and make then sensitive to the fact that your application has already started. As an example, rather than having every Test Case starting your app, you would have your first Test Case start the application and the second (and all others) go to a “home” page, or some location, where you can carry on into the next Test Case.

I want to check Login session active before every test case. I would like to condition my Login test to perform in such a way, If I’m unable to find the Home screen or if login screen appreared. How can I perform that?

This is my Login() method.

def appPath = PathUtil.relativeToAbsolutePath(GlobalVariable.androidApp, RunConfiguration.getProjectDir())

Mobile.startApplication(appPath, false)

Mobile.setText(findTestObject('Object Repository/Android_Mobile_Login/android.widget.UserName'), GlobalVariable.userName, 

Mobile.setEncryptedText(findTestObject('Object Repository/Android_Mobile_Login/android.widget.Password'), GlobalVariable.password, 

I am confused by this sentence.

Do you want to do this ? :

  1. Login → Check Balance Test → Logout
  2. Login → Fund Transfer Test → Logout
  3. Login → Utility Payment Test → Logout

If this is not what you want, then please reword it appropriately.

I want to run tests like this manner.

  1. Login → Check Balance Test
  2. Fund Transfer Test
  3. Utility Payment Test → Logout

After running few tests my Login session got expired or timed out. In that case the application login page will get appeared. So before proceed with the next case I need to login.

I want to call the Login test, If ( session expired or Home page not present or login screen appreared)

Are there any words or text that indicate your session has expired or timed out? If there are, then you can test for that text being present and then run your login routine which you can have as a Keyword if you want.


if (Mobile.verifyElementText(findTestObject(...), "specific expired text"))) {

And you have the code for LoginPage in your post above.


Do you mean, your app forces a Login session expired even while a user is operating it ; checking his balance, transfering his funds, paying for something, etc ?

If so, your app is seriously buggy; as buggy as any automated testing can’t cope with. You need to fix the bug of your app first before testing it in Katalon Studio.

… but I doubt my guess. Perhaps I still do not understand your problem.

No, App will not expire the session when a user actively operating it. For security reasons the app login session is valid of some specified time also if it is idle for a specified time then the session will get expired. I have multiple cases to run in a test suite.

I would like to handle this scenario in my Login method.

Yet I do not understand what you mean by “hadling this scenario”.

Do you want your test to be idle for a specified duration (seconds)?

Then, the following line will make your test case to block for 10 minutes.

WebUI.delay(10 * 60 * 60)

It is sufficient, isn’t it?

@kazurayam - Sorry for the confusion.

My requirement is run the login test before any testcase/test suite and if there is already existing login session available then it should skip the login and use the existing login session. It should not launch the application again.

I don’t know how to do it. So I will quit.

So you should find a way to detect if your AUT is authenticated or not and handle that appropriately in whatever manner.

Once you figure out this, we can guide you further.
The AUT is at your hands.

If each test ends properly, then you should be at a predefined page. You might be able to check if there is a specific element on that page and then continue. If the specific element is not present, then you might have to log in again or FAIL your test.

1 Like