How to launch an installed app using Katalon Studio

Hi,
I have developed simple app hello world. I want to open that app when i launch my Katalon project and then click on button.
It is possible to do that using katalon studio?

thanks
–girija

Did you mean mobile app? Generally, the answer is “Yes”. We need more information about your app, though.

Yes i am mobile app. It is a Android app. Its a third party app so i don’t have access to code. It performs certain operations after clicking on those buttons.

Suppose I write hello world Mobile app and i need to open that when i start my testing. Take example google map when i run my test project I have device connected and i need to start the map app which in on Android mobile

You can do it if you know appPackage and appActivty desired capabilities of your app. These coupled capabilities used to identify the application in your device. There links will provide you an approach to get it:

http://toolsqa.com/mobile-automation/appium/how-to-find-apppackage-and-appactivity-for-apk-file/

Once you have this information, you need to build your own set of Appium desired capabilities and then use Katalon built-in interface to translate that session into Katalon-like session (Appium based of course).

Here is how this approach can be applied with Kobiton devices, of course it can be applied for local devices as well due to being the same context:
https://docs.katalon.com/katalon-studio/docs/use-additional-desired-capabilities-for-kobiton-devices.html

1 Like

Vinh thanks for the response. I will check it out and let you know how did it go.

Hi Vinh

I am not able to find how to use appPackage and appActivity. I know using Android studio but I am not sure how to use here in Katalon. I didn’t find any example. I did looked at the both the links you sent but did not work for me. Do you have any other suggestion?

I will provide to you an example soon :slight_smile:

1 Like

Hi there,

Attached is the sample project using the same approach I’ve given before. Before jumping into this project, make sure you read our approach carefully to understand why do we need to define these own capabilities by yourself, and have a brief read about Appium architecture

Looking at this project, some things to be noticed:

  • Appium is started manually with the help of AppiumServer utilitiy, and of course it will be terminated right after test execution. For the current instance of this project, these setup and teardown steps are placed on Listeners script.
  • The actual custom keyword is: startInstalledApplication in com.mobile.keywords package. Since Android and iOS are different mobile types, I separate them conditionally. This keyword also initialize necessary capabilities to start installed application (using appPackage and appAcvitity capabilities) in the current device through deviceInformation parameter.

Now let’s move on why we need to do this:

  • When using Start Application built-in keyword, Katalon Studio will automatically start an Appium server using random port. We need a static port here to hook into.
  • Starting installed application requires us to build Appium desired capabilities from scratch, so startInstalledApplication will do all these things.

References to get capabilities:
https://www.toolsqa.com/mobile-automation/appium/how-to-find-apppackage-and-appactivity-for-apk-file/
http://appium.io/docs/en/writing-running-appium/caps/

Usage in the test case Test Cases/Verify Correct Alarm Message:

  • Local variables should be created to define necessary capabilities:
  • In the test script, just replace Start Application keyword with the custom keyword along with its method signature:
    //Mobile.startApplication(appPath, false) CustomKeywords.'com.mobile.keywords.ApplicationBehavior.startInstalledApplication'("Android", deviceInformation, appPackage, appActivity)
    => Once Test Suite execution happens (because my Listeners script belongs to Test Suite execution phase), Katalon Studio can start an existing application in the device and further Mobile keywords don’t need to be maintained.

This is the most basic implementation to solve ‘How to launch an installed app using Katalon Studio’. Other adjustments can be made to applied for Test Case execution phase based on Listeners script.
mobile.zip (2.5 MB)

3 Likes

The above comment has been reposted as a Tips and Tricks article.

1 Like

I did everything specified in the documents/links above specified but i am getting error:

Test Cases/Verify Correct Alarm Message FAILED.
Reason:
java.lang.ClassNotFoundException: com.mobile.keywords.ApplicationBehavior
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.getCustomKeywordClassAndSetMetaClass(CustomKeywordDelegatingMetaClass.java:98)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:44)
at Verify Correct Alarm Message.run(Verify Correct Alarm Message:25)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1547858698156.run(TempTestCase1547858698156.groovy:22)

Here is my test case:

import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import internal.GlobalVariable as GlobalVariable
import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.util.internal.PathUtil as PathUtil
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint

Mobile.comment(‘Story: Verify correct alarm message’)

Mobile.comment(‘Given that user has started an application’)

‘Get full directory’s path of android application’
def appPath = PathUtil.relativeToAbsolutePath(GlobalVariable.G_AndroidApp, RunConfiguration.getProjectDir())

//Mobile.startApplication(appPath, false)
CustomKeywords.‘com.mobile.keywords.ApplicationBehavior.startInstalledApplication’(“Android”, deviceInformation, appPackage, appActivity)

/*
Mobile.comment(‘And he navigates the application to Activity form’)

Mobile.tap(findTestObject(‘Application/android.widget.TextView - App’), 10)

Mobile.tap(findTestObject(‘Application/App/android.widget.TextView-Activity’), 10)

Mobile.comment(‘When he taps on the Custom Dialog button’)

Mobile.tap(findTestObject(‘Application/App/Activity/android.widget.TextView-Custom Dialog’), 10)

‘Get displayed message on the dialog’
def message = Mobile.getText(findTestObject(‘Application/App/Activity/Custom Dialog/android.widget.TextViewCustomDialog’),
10)

Mobile.comment(‘Then the correct dialog message should be displayed’)

Mobile.verifyEqual(message, ‘Example of how you can use a custom Theme.Dialog theme to make an activity that looks like a customized dialog, here with an ugly frame.’)

*/
Mobile.closeApplication()

Yes mobile App

Hi @girija_aj,

From your error message, it looks like your test can’t find the com.mobile.keywords.ApplicationBehavior class.
Can you verify that you see it when expanding your Tests Explorer, like this:

If not, you should download @Zarashima’s mobile.zip file from above and copy the Keywords folder into your own test’s Keywords folder.

Hope this helps,

Chris

Hi,

I have the same problem.
How can i run your project mobile.zip?

when i run i have only done

Hi @ouknam,

Could you please explain what you’re trying to test, what you’ve tried, and what is going wrong?

If you’re trying to run an existing app on a device or simulator, then this post might help:

Or if you follow the instructions above from this post, you can unzip the mobile.zip file mentioned in the post, then open the Android Mobile Tests with Katalon Studio.prj file within it:

Hope this helps,

– Chris

Is there a solution for install ipa file?