Refreshing the application data before each test case without restarting

i’ am working on automation of an android mobile application .In my test suite that start the application once and perform all the tests. I want to clear the application cache before running some tests without restarting the application. Is there any command/function, that can achieve the purpose? Thanks.

Hi,

Welcome to our community. I have not seen any cleaning cache mid-testing yet. How about others?

what about just clearing the text field !! i just want to refresh the application before executing the next test case do you get me ?! and thank for your time i really appreciate it

Maybe the following link might assist you:

If you just want to clear the text field, then maybe the below. Go for it.

hi @hajar20abouyahia

the uiautomator2 driver has a command for exactly this, it clears the app data like a fresh install without touching the session:

import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory

def driver = MobileDriverFactory.getDriver()
driver.executeScript('mobile: clearApp', [appId: 'com.yourcompany.app'])
driver.executeScript('mobile: activateApp', [appId: 'com.yourcompany.app'])

clearApp is the same as adb shell pm clear, so the app is force stopped and its storage wiped. activateApp brings it back to the foreground in a second, much faster than Mobile.startApplication which reinstalls. put the two lines in a @BeforeTestCase listener for the suite where you need a clean state.

if you only want the fields reset and not the data, Mobile.clearText per field is the way, there is no “reset the form” command, the app would have to offer that itself.