The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach. |
Description
Use the Exists
method to check whether the specified file or folder exists on the connected Android device.
Declaration
FileSystemManagerObj.Exists(Path)
FileSystemManagerObj | An expression, variable or parameter that specifies a reference to a FileSystemManager object | |||
Path | [in] | Required | String | |
Result | Boolean |
Applies To
The method is applied to the following object:
Parameters
The method has the following parameter:
Path
Specifies the fully-qualified path (including the name) of the file or folder to be checked. Case-sensitive.
Result Value
True if the specified file or folder exists; False otherwise.
Example
The sample code below demonstrates how to use the method to check whether a file exists:
JavaScript, JScript
function Test()
{
var fileSystemManager = Mobile.Device("MyDevice").FileSystemManager;
var path = "system/app/Calculator.apk";
if (fileSystemManager.Exists(path))
Log.Message("The " + path + " file has been found.");
else
Log.Warning("The " + path + " file does not exist on the Android device.");
}
Python
def Test():
fileSystemManager = Mobile.Device("MyDevice").FileSystemManager
path = "system/app/Calculator.apk"
if fileSystemManager.Exists(path):
Log.Message("The " + path + " file has been found.")
else:
Log.Warning("The " + path + " file does not exist on the Android device.")
VBScript
Sub Test
Set fileSystemManager = Mobile.Device("MyDevice").FileSystemManager
path = "system/app/Calculator.apk"
If fileSystemManager.Exists(path) Then
Log.Message("The " + path + " file has been found.")
Else
Log.Warning("The " + path + " file does not exist on the Android device.")
End If
End Sub
DelphiScript
procedure Test();
var fileSystemManager, path;
begin
fileSystemManager := Mobile.Device('MyDevice').FileSystemManager;
path := 'system/app/Calculator.apk';
if fileSystemManager.Exists(path) then
Log.Message('The ' + path + ' file has been found.')
else
Log.Warning('The ' + path + ' file does not exist on the Android device.');
end;
C++Script, C#Script
function Test()
{
var fileSystemManager = Mobile.Device("MyDevice").FileSystemManager;
var path = "system/app/Calculator.apk";
if (fileSystemManager.Exists(path))
Log.Message("The " + path + " file has been found.");
else
Log.Warning("The " + path + " file does not exist on the Android device.");
}
See Also
FileSystemManager Object
Testing Android Applications (Legacy)