Start installed mobile application in Katalon Studio

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

Explainations

  • Appium server is started manually with the help of AppiumServer utilitiy, and of course it will be terminated right after test execution based on where it is called. 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.

The key interface to let Katalon Studio re-use Appium session started by vanilla AppiumDriverLocalService is:

AppiumDriverManager.createMobileDriver(DriverType driverType, DesiredCapabilities capabilities, URL appiumServerUrl)

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 to prevent ports confliction. We need a static port here to hook into as we start Appium server by our own.
  • 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. appPackage and appActivity here is the API Demo application included and used in Katalon sample project.

  • 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)

  • Execute Regression Tests Test Suite. 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.

[Appium]e[39m Welcome to Appium v1.11.0-beta.2
e[35m[Appium]e[39m Appium REST http interface listener started on 0.0.0.0:4723
e[35m[HTTP]e[39m e[37m-->e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m
e[35m[HTTP]e[39m e[90m{}e[39m
[debug] e[35m[GENERIC]e[39m Calling AppiumDriver.getStatus() with args: []
[debug] e[35m[GENERIC]e[39m Responding to client with driver.getStatus() result: {"build":{"version":"1.11.0-beta.2"}}
e[35m[HTTP]e[39m e[37m<-- GET /wd/hub/status e[39me[32m200e[39m e[90m8 ms - 75e[39m
e[35m[HTTP]e[39m e[90me[39m
2019-01-06 19:00:15.342 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor   -e[0;39m e[39m--------------------e[0;39m
2019-01-06 19:00:15.342 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor   -e[0;39m e[39mSTART Test Cases/Verify Correct Alarm Messagee[0;39m
2019-01-06 19:00:15.509 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor   -e[0;39m e[39m(Default) appPackage = com.hmh.apie[0;39m
2019-01-06 19:00:15.520 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor   -e[0;39m e[39m(Default) appActivity = .ApiDemose[0;39m
2019-01-06 19:00:15.529 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor   -e[0;39m e[39m(Default) deviceInformation = {platformVersion=8.0.0, deviceName=SM-G965F, platformName=Android}e[0;39m
2019-01-06 19:00:15.819 e[39mDEBUGe[0;39m e[36mtestcase.Verify Correct Alarm Message    -e[0;39m e[39m1: comment("Story: Verify correct alarm message")e[0;39m
2019-01-06 19:00:15.876 e[39mDEBUGe[0;39m e[36mtestcase.Verify Correct Alarm Message    -e[0;39m e[39m2: comment("Given that user has started an application")e[0;39m
2019-01-06 19:00:15.879 e[39mDEBUGe[0;39m e[36mtestcase.Verify Correct Alarm Message    -e[0;39m e[39m3: com.mobile.keywords.ApplicationBehavior.startInstalledApplication("Android", deviceInformation, appPackage, appActivity)e[0;39m
e[35m[HTTP]e[39m e[37m-->e[39m e[37mPOSTe[39m e[37m/wd/hub/sessione[39m
e[35m[HTTP]e[39m e[90m{"desiredCapabilities":{"appActivity":".ApiDemos","appPackage":"com.hmh.api","deviceName":"SM-G965F","platformName":"Android","platformVersion":"8.0.0"},"capabilities":{"desiredCapabilities":{"appActivity":".ApiDemos","appPackage":"com.hmh.api","deviceName":"SM-G965F","platformName":"Android","platformVersion":"8.0.0"},"firstMatch":[{"platformName":"android"}]}}e[39m
[debug] e[35m[W3C]e[39m Calling AppiumDriver.createSession() with args: [{"appActivity":".ApiDemos","appPackage":"com.hmh.api","deviceName":"SM-G965F","platformName":"Android","platformVersion":"8.0.0"},null,{"desiredCapabilities":{"appActivity":".ApiDemos","appPackage":"com.hmh.api","deviceName":"SM-G965F","platformName":"Android","platformVersion":"8.0.0"},"firstMatch":[{"platformName":"android"}]}]
[debug] e[35m[BaseDriver]e[39m Event 'newSessionRequested' logged at 1546776016879 (19:00:16 GMT+0700 (SE Asia Standard Time))
e[35m[Appium]e[39m Could not parse W3C capabilities: 'deviceName' can't be blank
e[35m[Appium]e[39m Trying to fix W3C capabilities by merging them with JSONWP caps
e[35m[BaseDriver]e[39m The capabilities ["appActivity","appPackage","deviceName","platformVersion"] are not standard capabilities and should have an extension prefix
e[35m[Appium]e[39m Consider setting 'automationName' capability to 'UiAutomator2' on Android >= 6, since UIAutomator framework is not maintained anymore by the OS vendor.
e[35m[Appium]e[39m Creating new AndroidDriver (v4.8.0) session
e[35m[Appium]e[39m Capabilities:
e[35m[Appium]e[39m   appActivity: .ApiDemos
e[35m[Appium]e[39m   appPackage: com.hmh.api
e[35m[Appium]e[39m   deviceName: SM-G965F
e[35m[Appium]e[39m   platformVersion: 8.0.0
e[35m[Appium]e[39m   platformName: android
[debug] e[35m[BaseDriver]e[39m W3C capabilities {"alwaysMatch":{"appium:app... and MJSONWP desired capabilities {"appActivity":".ApiDemos",... were provided
[debug] e[35m[BaseDriver]e[39m Creating session with W3C capabilities: {"alwaysMatch":{"appium:app...
e[35m[BaseDriver]e[39m Session created with session id: e27ea67f-b1b7-4f8d-9ff8-086ddf059d80
e[35m[AndroidDriver]e[39m Java version is: 1.8.0_181

e[35m[ADB]e[39m Checking whether adb is present
e[35m[ADB]e[39m Found 1 'build-tools' folders under 'C:\Users\Admin\.katalon\tools\android_sdk' (newest first):
e[35m[ADB]e[39m     C:/Users/Admin/.katalon/tools/android_sdk/build-tools/27.0.1
e[35m[ADB]e[39m Using adb.exe from C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe
e[35m[AndroidDriver]e[39m Retrieving device list
[debug] e[35m[ADB]e[39m Trying to find a connected android device
[debug] e[35m[ADB]e[39m Getting connected devices...
[debug] e[35m[ADB]e[39m 1 device(s) connected
e[35m[AndroidDriver]e[39m Looking for a device with Android '8.0.0'
[debug] e[35m[ADB]e[39m Setting device id to 1bd4b04603047ece
e[35m[ADB]e[39m Getting device platform version
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell getprop ro.build.version.release'
[debug] e[35m[ADB]e[39m Current device property 'ro.build.version.release': 8.0.0
e[35m[AndroidDriver]e[39m Using device: 1bd4b04603047ece
[debug] e[35m[ADB]e[39m Setting device id to 1bd4b04603047ece
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell getprop ro.build.version.sdk'
[debug] e[35m[ADB]e[39m Current device property 'ro.build.version.sdk': 26
[debug] e[35m[ADB]e[39m Device API level: 26
e[35m[AndroidDriver]e[39m Consider setting 'automationName' capability to 'uiautomator2' on Android >= 6, since UIAutomator framework is not maintained anymore by the OS vendor.
e[35m[AndroidDriver]e[39m App file was not listed, instead we're going to run com.hmh.api directly on the device
[debug] e[35m[AndroidDriver]e[39m Checking whether package is present on the device
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell pm list packages com.hmh.api'
e[35m[AndroidDriver]e[39m Starting Android session
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece wait-for-device'
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell echo ping'
[debug] e[35m[AndroidDriver]e[39m Pushing settings apk to device...
[debug] e[35m[ADB]e[39m Getting install status for io.appium.settings
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell dumpsys package io.appium.settings'
[debug] e[35m[ADB]e[39m 'io.appium.settings' is installed
[debug] e[35m[ADB]e[39m Getting package info for 'io.appium.settings'
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell dumpsys package io.appium.settings'
e[35m[ADB]e[39m Checking whether aapt is present
e[35m[ADB]e[39m Using aapt.exe from C:\Users\Admin\.katalon\tools\android_sdk\build-tools\27.0.1\aapt.exe
[debug] e[35m[ADB]e[39m The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('2.11.0' >= '2.11.0')
[debug] e[35m[ADB]e[39m There is no need to install/upgrade 'C:\Users\Admin\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk'
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell ps'
[debug] e[35m[ADB]e[39m Device API level: 26
[debug] e[35m[ADB]e[39m Device API level: 26
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
[debug] e[35m[ADB]e[39m Device API level: 26
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell appops set io.appium.settings android\:mock_location allow'
[debug] e[35m[Logcat]e[39m Starting logcat capture
e[35m[ADB]e[39m Getting device platform version
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell getprop ro.build.version.release'
[debug] e[35m[ADB]e[39m Current device property 'ro.build.version.release': 8.0.0
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell wm size'
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell getprop ro.product.model'
[debug] e[35m[ADB]e[39m Current device property 'ro.product.model': SM-G965F
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell getprop ro.product.manufacturer'
[debug] e[35m[ADB]e[39m Current device property 'ro.product.manufacturer': samsung
e[35m[AndroidDriver]e[39m No app sent in, not parsing package/activity
[debug] e[35m[AndroidDriver]e[39m No app capability. Assuming it is already on the device
[debug] e[35m[ADB]e[39m Getting install status for com.hmh.api
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell dumpsys package com.hmh.api'
[debug] e[35m[ADB]e[39m 'com.hmh.api' is installed
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell am force-stop com.hmh.api'
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell pm clear com.hmh.api'
[debug] e[35m[AndroidDriver]e[39m Performed fast reset on the installed 'com.hmh.api' application (stop and clear)
[debug] e[35m[AndroidBootstrap]e[39m Watching for bootstrap disconnect
[debug] e[35m[ADB]e[39m Forwarding system: 4724 to device: 4724
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece forward tcp\:4724 tcp\:4724'
[debug] e[35m[UiAutomator]e[39m Starting UiAutomator
[debug] e[35m[UiAutomator]e[39m Moving to state 'starting'
[debug] e[35m[UiAutomator]e[39m Parsing uiautomator jar
[debug] e[35m[UiAutomator]e[39m Found jar name: 'AppiumBootstrap.jar'
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece push C\:\\Users\\Admin\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-android-driver\\bootstrap\\bin\\AppiumBootstrap.jar /data/local/tmp/'
[debug] e[35m[ADB]e[39m Attempting to kill all uiautomator processes
[debug] e[35m[ADB]e[39m Getting all processes with uiautomator
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell ps'
e[35m[ADB]e[39m No 'uiautomator' process has been found
[debug] e[35m[UiAutomator]e[39m Starting UIAutomator
[debug] e[35m[ADB]e[39m Creating ADB subprocess with args: ["-P",5037,"-s","1bd4b04603047ece","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.hmh.api","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
[debug] e[35m[UiAutomator]e[39m Moving to state 'online'
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] json loading complete.
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Registered crash watchers.
e[35m[AndroidBootstrap]e[39m Android bootstrap socket is now connected
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell dumpsys window'
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Client connected
e[35m[AndroidDriver]e[39m Screen already unlocked, doing nothing
[debug] e[35m[ADB]e[39m Device API level: 26
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell am start -W -n com.hmh.api/.ApiDemos -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
e[35m[Appium]e[39m New AndroidDriver session created successfully, session e27ea67f-b1b7-4f8d-9ff8-086ddf059d80 added to master session list
[debug] e[35m[BaseDriver]e[39m Event 'newSessionStarted' logged at 1546776022746 (19:00:22 GMT+0700 (SE Asia Standard Time))
[debug] e[35m[W3C (e27ea67f)]e[39m Cached the protocol value 'W3C' for the new session e27ea67f-b1b7-4f8d-9ff8-086ddf059d80
[debug] e[35m[W3C (e27ea67f)]e[39m Responding to client with driver.createSession() result: {"capabilities":{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"android","appActivity":".ApiDemos","appPackage":"com.hmh.api","deviceName":"SM-G965F","platformVersion":"8.0.0"},"platformName":"android","appActivity":".ApiDemos","appPackage":"com.hmh.api","deviceName":"1bd4b04603047ece","platformVersion":"8.0.0","deviceUDID":"1bd4b04603047ece","deviceScreenSize":"1440x2960","deviceModel":"SM-G965F","deviceManufacturer":"samsung"}}
e[35m[HTTP]e[39m e[37m<-- POST /wd/hub/session e[39me[32m200e[39m e[90m5870 ms - 668e[39m
e[35m[HTTP]e[39m e[90me[39m
Jan 06, 2019 7:00:22 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
e[35m[HTTP]e[39m e[37m-->e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m
e[35m[HTTP]e[39m e[90m{}e[39m
[debug] e[35m[GENERIC]e[39m Calling AppiumDriver.getStatus() with args: []
[debug] e[35m[GENERIC]e[39m Responding to client with driver.getStatus() result: {"build":{"version":"1.11.0-beta.2"}}
e[35m[HTTP]e[39m e[37m<-- GET /wd/hub/status e[39me[32m200e[39m e[90m1 ms - 75e[39m
e[35m[HTTP]e[39m e[90me[39m
2019-01-06 19:00:22.801 e[34mINFO e[0;39m e[36mc.k.k.c.a.driver.AppiumRequestService    -e[0;39m e[39mappiumVersion = 1.11.0-beta.2e[0;39m
e[35m[HTTP]e[39m e[37m-->e[39m e[37mPOSTe[39m e[37m/wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/timeoutse[39m
e[35m[HTTP]e[39m e[90m{"implicit":30000}e[39m
[debug] e[35m[W3C (e27ea67f)]e[39m Calling AppiumDriver.timeouts() with args: [null,null,null,null,30000,"e27ea67f-b1b7-4f8d-9ff8-086ddf059d80"]
[debug] e[35m[BaseDriver]e[39m W3C timeout argument: {"implicit":30000}}
[debug] e[35m[BaseDriver]e[39m Set implicit wait to 30000ms
[debug] e[35m[W3C (e27ea67f)]e[39m Responding to client with driver.timeouts() result: null
e[35m[HTTP]e[39m e[37m<-- POST /wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/timeouts e[39me[32m200e[39m e[90m15 ms - 14e[39m
e[35m[HTTP]e[39m e[90me[39m
2019-01-06 19:00:22.824 e[34mINFO e[0;39m e[36mc.k.k.c.a.driver.AppiumDriverManager     -e[0;39m e[39mdeviceId = nulle[0;39m
2019-01-06 19:00:22.824 e[34mINFO e[0;39m e[36mc.k.k.c.a.driver.AppiumDriverManager     -e[0;39m e[39mdeviceName = nulle[0;39m
2019-01-06 19:00:22.825 e[34mINFO e[0;39m e[36mc.k.k.c.a.driver.AppiumDriverManager     -e[0;39m e[39mdeviceModel = nulle[0;39m
2019-01-06 19:00:22.825 e[34mINFO e[0;39m e[36mc.k.k.c.a.driver.AppiumDriverManager     -e[0;39m e[39mdeviceManufacturer = nulle[0;39m
2019-01-06 19:00:22.825 e[34mINFO e[0;39m e[36mc.k.k.c.a.driver.AppiumDriverManager     -e[0;39m e[39mdeviceOS = nulle[0;39m
2019-01-06 19:00:22.826 e[34mINFO e[0;39m e[36mc.k.k.c.a.driver.AppiumDriverManager     -e[0;39m e[39mdeviceOSVersion = nulle[0;39m
2019-01-06 19:00:22.826 e[34mINFO e[0;39m e[36mk.k.c.m.CustomKeywordDelegatingMetaClass -e[0;39m e[39mcom.mobile.keywords.ApplicationBehavior.startInstalledApplication is PASSEDe[0;39m
2019-01-06 19:00:22.827 e[39mDEBUGe[0;39m e[36mtestcase.Verify Correct Alarm Message    -e[0;39m e[39m4: comment("And he navigates the application to Activity form")e[0;39m
2019-01-06 19:00:22.828 e[39mDEBUGe[0;39m e[36mtestcase.Verify Correct Alarm Message    -e[0;39m e[39m5: tap(findTestObject("Application/android.widget.TextView - App"), 10)e[0;39m
e[35m[HTTP]e[39m e[37m-->e[39m e[37mGETe[39m e[37m/wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/window/recte[39m
e[35m[HTTP]e[39m e[90m{}e[39m
[debug] e[35m[W3C (e27ea67f)]e[39m Calling AppiumDriver.getWindowRect() with args: ["e27ea67f-b1b7-4f8d-9ff8-086ddf059d80"]
[debug] e[35m[AndroidBootstrap]e[39m Sending command to android: {"cmd":"action","action":"getDeviceSize","params":{}}
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"getDeviceSize","params":{}}
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Got command action: getDeviceSize
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"height":2792,"width":1440}}
[debug] e[35m[AndroidBootstrap]e[39m Received command result from bootstrap
[debug] e[35m[W3C (e27ea67f)]e[39m Responding to client with driver.getWindowRect() result: {"width":1440,"height":2792,"x":0,"y":0}
e[35m[HTTP]e[39m e[37m<-- GET /wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/window/rect e[39me[32m200e[39m e[90m17 ms - 50e[39m
e[35m[HTTP]e[39m e[90me[39m
e[35m[HTTP]e[39m e[37m-->e[39m e[37mPOSTe[39m e[37m/wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/elementse[39m
e[35m[HTTP]e[39m e[90m{"value":"new UiSelector().className(\"android.widget.TextView\").text(\"App\").resourceId(\"android:id/text1\").instance(3)","using":"-android uiautomator"}e[39m
[debug] e[35m[W3C (e27ea67f)]e[39m Calling AppiumDriver.findElements() with args: ["-android uiautomator","new UiSelector().className(\"android.widget.TextView\").text(\"App\").resourceId(\"android:id/text1\").instance(3)","e27ea67f-b1b7-4f8d-9ff8-086ddf059d80"]
[debug] e[35m[BaseDriver]e[39m Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] e[35m[BaseDriver]e[39m Waiting up to 30000 ms for condition
[debug] e[35m[AndroidBootstrap]e[39m Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().className(\"android.widget.TextView\").text(\"App\").resourceId(\"android:id/text1\").instance(3)","context":"","multiple":true}}
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().className(\"android.widget.TextView\").text(\"App\").resourceId(\"android:id/text1\").instance(3)","context":"","multiple":true}}
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Got command action: find
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Finding 'new UiSelector().className("android.widget.TextView").text("App").resourceId("android:id/text1").instance(3)' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: true
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().className("android.widget.TextView").text("App").resourceId("android:id/text1").instance(3)
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] UiSelector coerce type: java.lang.Class<T> arg: "android.widget.TextView"
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "android.widget.TextView"
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "App"
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "android:id/text1"
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] UiSelector coerce type: int arg: 3
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Using: UiSelector[TEXT=App, CLASS=android.widget.TextView, INSTANCE=3, RESOURCE_ID=android:id/text1]
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[TEXT=App, CLASS=android.widget.TextView, INSTANCE=3, RESOURCE_ID=android:id/text1]
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Element[] is null: (0)
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[TEXT=App, CLASS=android.widget.TextView, INSTANCE=0, RESOURCE_ID=android:id/text1]
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Element[] is null: (1)
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[TEXT=App, CLASS=android.widget.TextView, INSTANCE=1, RESOURCE_ID=android:id/text1]
[debug] e[35m[AndroidBootstrap]e[39m [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":[{"ELEMENT":"1"}]}
[debug] e[35m[AndroidBootstrap]e[39m Received command result from bootstrap
[debug] e[35m[W3C (e27ea67f)]e[39m Responding to client with driver.findElements() result: [{"element-6066-11e4-a52e-4f735466cecf":"1","ELEMENT":"1"}]
e[35m[HTTP]e[39m e[37m<-- POST /wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/elements e[39me[32m200e[39m e[90m281 ms - 69e[39m
e[35m[HTTP]e[39m e[90me[39m
e[35m[HTTP]e[39m e[37m-->e[39m e[37mGETe[39m e[37m/wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/contexte[39m
e[35m[HTTP]e[39m e[90m{}e[39m
[debug] e[35m[W3C (e27ea67f)]e[39m Calling AppiumDriver.getCurrentContext() with args: ["e27ea67f-b1b7-4f8d-9ff8-086ddf059d80"]
[debug] e[35m[W3C (e27ea67f)]e[39m Responding to client with driver.getCurrentContext() result: "NATIVE_APP"
e[35m[HTTP]e[39m e[37m<-- GET /wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/context e[39me[32m200e[39m e[90m2 ms - 22e[39m
e[35m[HTTP]e[39m e[90me[39m
e[35m[HTTP]e[39m e[37m-->e[39m e[37mGETe[39m e[37m/wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/contextse[39m
e[35m[HTTP]e[39m e[90m{}e[39m
[debug] e[35m[W3C (e27ea67f)]e[39m Calling AppiumDriver.getContexts() with args: ["e27ea67f-b1b7-4f8d-9ff8-086ddf059d80"]
[debug] e[35m[AndroidDriver]e[39m Getting a list of available webviews
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell cat /proc/net/unix'
[debug] e[35m[AndroidDriver]e[39m Found webviews: ["WEBVIEW_chrome"]
[debug] e[35m[AndroidDriver]e[39m Available contexts: ["NATIVE_APP","WEBVIEW_chrome"]
[debug] e[35m[W3C (e27ea67f)]e[39m Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_chrome"]
e[35m[HTTP]e[39m e[37m<-- GET /wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/contexts e[39me[32m200e[39m e[90m73 ms - 41e[39m
e[35m[HTTP]e[39m e[90me[39m
e[35m[HTTP]e[39m e[37m-->e[39m e[37mPOSTe[39m e[37m/wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/contexte[39m
e[35m[HTTP]e[39m e[90m{"name":"NATIVE_APP"}e[39m
[debug] e[35m[W3C (e27ea67f)]e[39m Calling AppiumDriver.setContext() with args: ["NATIVE_APP","e27ea67f-b1b7-4f8d-9ff8-086ddf059d80"]
[debug] e[35m[AndroidDriver]e[39m Getting a list of available webviews
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell cat /proc/net/unix'
[debug] e[35m[AndroidDriver]e[39m Found webviews: ["WEBVIEW_chrome"]
[debug] e[35m[AndroidDriver]e[39m Available contexts: ["NATIVE_APP","WEBVIEW_chrome"]
[debug] e[35m[W3C (e27ea67f)]e[39m Responding to client with driver.setContext() result: null
e[35m[HTTP]e[39m e[37m<-- POST /wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/context e[39me[32m200e[39m e[90m81 ms - 14e[39m
e[35m[HTTP]e[39m e[90me[39m
e[35m[HTTP]e[39m e[37m-->e[39m e[37mGETe[39m e[37m/wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/screenshote[39m
e[35m[HTTP]e[39m e[90m{}e[39m
[debug] e[35m[W3C (e27ea67f)]e[39m Calling AppiumDriver.getScreenshot() with args: ["e27ea67f-b1b7-4f8d-9ff8-086ddf059d80"]
[debug] e[35m[ADB]e[39m Device API level: 26
[debug] e[35m[W3C (e27ea67f)]e[39m Responding to client with driver.getScreenshot() result: "iVBORw0KGgoAAAANSUhEUgAABaAAAAuQCAYAAAD85Zg4AAH+CElEQVR4AezBf3TThb34/2d+9Nf7XVqgDT+Fvisg0DAEIVXAQVBQpFRwCtvUSWHXqWFz9w9Bz+785A3b3Y7guZ7d2WyKbnDVbXcVHSqgIBhkFSQgTAgqILzLD/mRUuyPpKVNk+/J+Z6cTz45LRRosODr8TABUYQQQgghhBBCCCGEEEKITmZGCCGEEEIIIYQQQgghhEgBM0IIIYQQQgghhBBCCCFECpgRQgghhBBCCCGEEEIIIVLAjBBCCCGEEEIIIYQQQgiRAmaEEEIIIYQQQgghhBBCiBQwI4QQQgghhBBCCCGEEEKkgBkhhBBCCCGEEEIIIYQQIgXMCCGEEEIIIYQQQgghhBApYEYIIYQQQgghhBBCCCGESAEzQgghhBBCCCGEEEIIIUQKmBFCCCGEEEIIIYQQQgghUsCMEEIIIYQQQgghhBBCCJECZoQQQgghhBBCCCGEEEKIFDAjhBBCCCGEEEIIIYQQQqSAGSGEEEIIIYQQQgghhBAiBcwIIYQQQgghhBBCCCGEEClgRQghhBBCCCGEEJds+vTpOJ1ONE3jamAYBl6vl7Vr1yKEEEKkmgXQEUIIIYQQQgghxEVzuVzMmjWL7t27c7Xo3r07o0aNwmaz4fP5EEIIIVLJjBBCCCGEEEIIIS6a3W7H6XRytXI6ndjtdoQQQohUsiKEEEIIIYQQ4qpQVFREjKZpqKpKIsMwCAaDBAIBAoEAXU1RURGpUlVVRTAY5EorKioiLhAI4PV6uRo4nU5sNhsxRUVF+P1+rnaqqhKNRgmFQohvD7vdTlFRER2xb98+/H4/Qogrz4oQQgghhBBCCOx2O36/n65C0zSKioqw2+0UFRWhqioXwzAM/H4/+/btY9++fQSDQb4JdrudJ554AlVVSSWv18vKlSsJBoNcKXa7nbhAIEBFRQVXA7vdjs1mI8Zut1NRUcHVLDc3l1/+8pcsXbqUUCiE+HZwOBws...
e[35m[HTTP]e[39m e[37m<-- GET /wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/screenshot e[39me[32m200e[39m e[90m1304 ms - 174180e[39m
e[35m[HTTP]e[39m e[90me[39m
e[35m[HTTP]e[39m e[37m-->e[39m e[37mPOSTe[39m e[37m/wd/hub/session/e27ea67f-b1b7-4f8d-9ff8-086ddf059d80/contexte[39m
e[35m[HTTP]e[39m e[90m{"name":"NATIVE_APP"}e[39m
[debug] e[35m[W3C (e27ea67f)]e[39m Calling AppiumDriver.setContext() with args: ["NATIVE_APP","e27ea67f-b1b7-4f8d-9ff8-086ddf059d80"]
[debug] e[35m[AndroidDriver]e[39m Getting a list of available webviews
[debug] e[35m[ADB]e[39m Running 'C:\Users\Admin\.katalon\tools\android_sdk\platform-tools\adb.exe -P 5037 -s 1bd4b04603047ece shell cat /proc/net/unix'
[debug] e[35m[AndroidDriver]e[39m Found webviews: ["WEBVIEW_chrome"]

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

Greetings.

I’m trying to start installed GMail app on android studio emulator. Added described capabilities and custom script.

CustomKeywords.‘com.mobile.keywords.ApplicationBehavior.startInstalledApplication’(“Android”, deviceInformation, appPackage, appActivity)

But my test case fails with error:

Test Cases/Launch gmail FAILED.
Reason:
java.lang.ClassNotFoundException: com.mobile.keywords.ApplicationBehavior
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.getCustomKeywordClassAndSetMetaClass(CustomKeywordDelegatingMetaClass.java:100)

I am novice in Katalon studio. Did I miss something?

Hi mekx. Double check Keywords and Test Listeners within Tests Explorer on your project have been updated to match the same as the Keywords and Test Listeners on the mobile.zip example posted by Vinh_Nguyen.

Once done, ensure Appium is running. I did this and it is now working for me.