Katalon Studio Close Application Doesn't Work

I’m using Katalon Studio to test a mobile application. When I use Start Existing Application, the Close Application method doesn’t work. Example from my project of something that doesn’t work.

Code

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
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 static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
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.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

//Start the app and then get to the login page
Mobile.startExistingApplication(‘myApplication’)
Mobile.tap(findTestObject(‘Object Repository/Application/Login/android.widget.Button - ACKNOWLEDGE’), 2, FailureHandling.OPTIONAL)
Mobile.tap(findTestObject(‘Application/Login/android.widget.Button - LOGIN’), 2, FailureHandling.OPTIONAL)
// Input a correct username and wrong password
Mobile.setText(findTestObject(‘Application/Login/Username’), ‘fakeUsername’, 0)
Mobile.setText(findTestObject(‘Application/Login/Password’), ‘Wrong Password’, 0)
// Tap the middle of the login button. If you do a standard click it doesn’t work because it clicks outside the rounded edge
// Mobile.tapAtPosition(720, 2258)
String failureMessage = Mobile.getText(findTestObject(‘Object Repository/Application/Login/android.view.View - Unable to sign in’), 0)
assert failureMessage.equalsIgnoreCase(‘Unable to sign in’)
Mobile.closeApplication()

I have tested this and confirmed that it works when I start the application by installing the .apk from the Katalon project, but because of the way that our application needs to authenticate, we have to start it from the phone. I understand that I can get around this issue for most of my tests by logging out and relogging in, and that I don’t want to have to start and close the app between every test because that would be unnecessary and slow. That said, I think this is something that should be fixed because it’s a pretty important part of the core Katalon mobile testing.

@Elly_Tran
Can confirm that keyword in KSE 8.6.8 does not close application.
Katalon team - please can you suggest a fix for this, since no-code scripts will fail?
Expected results:
tester creates script to open an existing application, perform work, close application:

Actual results:
When script is recorded using Mobile Recorder, keywords ‘Start existing application’ and ‘Close application’ are inserted into script at start and end.
The script executes and opens application as planned. Script notifies that ‘Close application’ step has been successful but actually it is still open.
The next time the same script or another script runs, the app is still open at the screen it was left at by previous execution and the script fails since it cannot find the expected element.

This appears to be a bug rather than a feature request, since the ‘Close application’ step is inserted automatically yet does not perform the expected function and neither is there an alternative keyword to close the existing app.
using KSE 8.6.8 on Windows 10, Android phone running Power App application

Hi,

Thank you for letting me know. Can you please give some screenshot or error log if yes? Thank you

Hi,

Can you please try below mentioned code with the start existing keyword instead for close application.

Close the app by id.

AppiumDriver<?> driver = MobileDriverFactory.*getDriver*();

driver.terminateApp('App package name')
1 Like