# Katalon Studio Close Application Doesn't Work

**URL:** <https://forum.katalon.com/t/katalon-studio-close-application-doesnt-work/53900>\
**Category:** Mobile Testing\
**Tags:** mobile-testing, katalon-studio\
**Created:** [April 16, 2021, 3:02pm UTC](https://forum.katalon.com/t/katalon-studio-close-application-doesnt-work/53900 "2021-04-16T15:02:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rothompson](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rothompson/32/16103_2.png) [@rothompson](https://forum.katalon.com/u/rothompson)\
**Post date:** [April 16, 2021, 3:02pm UTC](https://forum.katalon.com/t/katalon-studio-close-application-doesnt-work/53900/1 "2021-04-16T15:02:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dan\_Bown](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/dan_bown/32/20464_2.png) [@Dan\_Bown](https://forum.katalon.com/u/Dan_Bown)\
**Post date:** [February 26, 2024, 2:36pm UTC](https://forum.katalon.com/t/katalon-studio-close-application-doesnt-work/53900/2 "2024-02-26T14:36:33Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![Elly\_Tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/elly_tran/32/21874_2.png) [@Elly\_Tran](https://forum.katalon.com/u/Elly_Tran)\
**Post date:** [February 27, 2024, 3:40am UTC](https://forum.katalon.com/t/katalon-studio-close-application-doesnt-work/53900/4 "2024-02-27T03:40:19Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![Elly\_Tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/elly_tran/32/21874_2.png) [@Elly\_Tran](https://forum.katalon.com/u/Elly_Tran)\
**Post date:** [March 13, 2024, 2:02am UTC](https://forum.katalon.com/t/katalon-studio-close-application-doesnt-work/53900/5 "2024-03-13T02:02:09Z")

</div>

Hi,

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

Close the app by id.

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

driver.terminateApp('App package name')

```
