Description
Specifies whether the application’s data and cache are removed from your Android device when you remove the application package from the device. The property value corresponds to the Keep the data and cache directories on removal option specified for the application in the TestedApps editor.
Declaration
AndroidTestedAppObj.KeepDataAndCache
Read-Write Property | Boolean |
AndroidTestedAppObj | An expression, variable or parameter that specifies a reference to an AndroidTestedApp object |
Applies To
The property is applied to the following object:
Property Value
True if all application data and cache are kept on your mobile device upon removing the application package. False otherwise.
Example
The sample code below demonstrates how to add a new Android application to the list of tested applications, check if it is instrumented (and instrument it if needed), specify the application’s properties and run the application.
JavaScript, JScript
function AddAndroidApplication()
{
// Sets the current device
Mobile.SetCurrent("MyDevice");
// Adds the Android application from the package and obtains its index in the list of tested applications
var ind = TestedApps.AddAndroidApp("C:\\Android\\apks\\SampleApp.apk");
// Obtains the added tested application by its index and specifies its properties
var AndroidTestedApp = TestedApps.Items(ind);
AndroidTestedApp.DeployOnStart = true;
AndroidTestedApp.Launch = true;
AndroidTestedApp.KeepDataAndCache = false;
// Checks if the applications is instrumented
if (!AndroidTestedApp.Instrumented)
{
// Sets up backup parameters
AndroidTestedApp.BackupOriginalAPK = true;
AndroidTestedApp.BackupFileName = "C:\\Android\\apks\\SampleApp_ORIGINAL_BACKUP.apk";
// Sets up custom certificate parameters
AndroidTestedApp.UseCustomCertificate = true;
AndroidTestedApp.KeystorePath = "C:\\Android\\Keystore";
AndroidTestedApp.KeystorePassword = "KstrPass";
AndroidTestedApp.Alias = "KeyAlias";
AndroidTestedApp.KeyPassword = "KeyPass";
AndroidTestedApp.Instrument();
}
// Checks if TestComplete can work with the instrumented application
if (AndroidTestedApp.InstrumentedWithSupportedVersion)
{
// Launches the application
AndroidTestedApp.Run();
}
else
{
// Posts an error to the log
Log.Error("Please use uninstrumented application or application instrumented for the current TestComplete version");
}
}
Python
def AddAndroidApplication():
# Sets the current device
Mobile.SetCurrent("MyDevice")
# Adds the Android application from the package and obtains its index in the list of tested applications
ind = TestedApps.AddAndroidApp("C:\\Android\\apks\\SampleApp.apk")
# Obtains the added tested application by its index and specifies its properties
AndroidTestedApp = TestedApps.Items[ind]
AndroidTestedApp.DeployOnStart = True
AndroidTestedApp.Launch = True
AndroidTestedApp.KeepDataAndCache = False
# Checks if the applications is instrumented
if (not AndroidTestedApp.Instrumented):
# Sets up backup parameters
AndroidTestedApp.BackupOriginalAPK = True
AndroidTestedApp.BackupFileName = "C:\\Android\\apks\\SampleApp_ORIGINAL_BACKUP.apk"
# Sets up custom certificate parameters
AndroidTestedApp.UseCustomCertificate = True
AndroidTestedApp.KeystorePath = "C:\\Android\\Keystore"
AndroidTestedApp.KeystorePassword = "KstrPass"
AndroidTestedApp.Alias = "KeyAlias"
AndroidTestedApp.KeyPassword = "KeyPass"
AndroidTestedApp.Instrument()
# Checks if TestComplete can work with the instrumented application
if (AndroidTestedApp.InstrumentedWithSupportedVersion):
# Launches the application
AndroidTestedApp.Run()
else:
# Posts an error to the log
Log.Error("Please use uninstrumented application or application instrumented for the current TestComplete version")
VBScript
Sub AddAndroidApplication
' Sets the current device
Mobile.SetCurrent("MyDevice")
' Adds the Android application from the package and obtains its index in the list of tested applications
ind = TestedApps.AddAndroidApp("C:\Android\apks\SampleApp.apk")
' Obtains the added tested application by its index and specifies its properties
Set AndroidTestedApp = TestedApps.Items(ind)
AndroidTestedApp.DeployOnStart = True
AndroidTestedApp.Launch = True
AndroidTestedApp.KeepDataAndCache = False
' Checks if the applications is instrumented
If not AndroidTestedApp.Instrumented Then
' Sets up backup parameters
AndroidTestedApp.BackupOriginalAPK = true
AndroidTestedApp.BackupFileName = "C:\Android\apks\SampleApp_ORIGINAL_BACKUP.apk"
' Sets up custom certificate parameters
AndroidTestedApp.UseCustomCertificate = true
AndroidTestedApp.KeystorePath = "C:\Android\Keystore"
AndroidTestedApp.KeystorePassword = "KstrPass"
AndroidTestedApp.Alias = "KeyAlias"
AndroidTestedApp.KeyPassword = "KeyPass"
' Instruments the application
AndroidTestedApp.Instrument()
End If
' Checks if TestComplete can work with the instrumented application
If AndroidTestedApp.InstrumentedWithSupportedVersion Then
' Launches the application
AndroidTestedApp.Run()
Else
' Posts an error to the log
Log.Error("Please use uninstrumented application or application instrumented for the current TestComplete version")
End If
End Sub
DelphiScript
procedure AddAndroidApplication();
var
ind, AndroidTestedApp;
begin
// Sets the current device
Mobile.SetCurrent('MyDevice');
// Adds the Android application from the package and obtains its index in the list of tested applications
ind := TestedApps.AddAndroidApp('C:\Android\apks\SampleApp.apk');
// Obtains the added tested application by its index and specifies its launch properties
AndroidTestedApp := TestedApps.Items[ind];
AndroidTestedApp.DeployOnStart := true;
AndroidTestedApp.Launch := true;
AndroidTestedApp.KeepDataAndCache := false;
// Checks if the applications is instrumented
if not AndroidTestedApp.Instrumented then
begin
// Sets up backup parameters
AndroidTestedApp.BackupOriginalAPK := true;
AndroidTestedApp.BackupFileName := 'C:\Android\apks\SampleApp_ORIGINAL_BACKUP.apk';
// Sets up custom certificate parameters
AndroidTestedApp.UseCustomCertificate := true;
AndroidTestedApp.KeystorePath := 'C:\Android\Keystore';
AndroidTestedApp.KeystorePassword := 'KstrPass';
AndroidTestedApp.Alias := 'KeyAlias';
AndroidTestedApp.KeyPassword := 'KeyPass';
// Instruments the application
AndroidTestedApp.Instrument();
end;
// Checks if TestComplete can work with the instrumented application
if AndroidTestedApp.InstrumentedWithSupportedVersion then
// Launches the application
AndroidTestedApp.Run()
else
// Posts an error to the log
Log.Error('Please use uninstrumented application or application instrumented for the current TestComplete version');
end;
C++Script, C#Script
function AddAndroidApplication()
{
// Sets the current device
Mobile["SetCurrent"]("MyDevice");
// Adds the Android application from the package and obtains its index in the list of tested applications
var ind = TestedApps["AddAndroidApp"]("C:\\Android\\apks\\SampleApp.apk");
// Obtains the added tested application by its index and specifies its properties
var AndroidTestedApp = TestedApps["Items"](ind);
AndroidTestedApp["DeployOnStart"] = true;
AndroidTestedApp["Launch"] = true;
AndroidTestedApp["KeepDataAndCache"] = false;
// Checks if the applications is instrumented
if (!AndroidTestedApp["Instrumented"])
{
// Sets up backup parameters
AndroidTestedApp["BackupOriginalAPK"] = true;
AndroidTestedApp["BackupFileName"] = "C:\\Android\\apks\\SampleApp_ORIGINAL_BACKUP.apk";
// Sets up custom certificate parameters
AndroidTestedApp["UseCustomCertificate"] = true;
AndroidTestedApp["KeystorePath"] = "C:\\Android\\Keystore";
AndroidTestedApp["KeystorePassword"] = "KstrPass";
AndroidTestedApp["Alias"] = "KeyAlias";
AndroidTestedApp["KeyPassword"] = "KeyPass";
// Instruments the application
AndroidTestedApp["Instrument"]();
}
// Checks if TestComplete can work with the instrumented application
if (AndroidTestedApp["InstrumentedWithSupportedVersion"])
{
// Launches the application
AndroidTestedApp["Run"]();
}
else
{
// Posts an error to the log
Log["Error"]("Please use uninstrumented application or application instrumented for the current TestComplete version");
}
}
See Also
DeployOnStart Property
AndroidTestedApp Object
About Tested Android Applications
About Tested Applications
Android Application Parameters