Delete Method

Applies to TestComplete 14.80, last modified on April 15, 2021
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 Delete method to remove the specified file of folder from the connected Android device.

Declaration

FileSystemManagerObj.Delete(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

The fully-qualified path (including the name) of the folder or file to be deleted. Case-sensitive.

Result Value

True if the file or folder has been deleted successfully; False otherwise.

Example

The sample code below demonstrates how to delete a file from the connected Android device:

JavaScript, JScript

function Test()
{

  var fileSystemManager = Mobile.Device("MyDevice").FileSystemManager;

  // Copies a file from the computer to the device
  var pathOnHost = "C:\\Work Folders\\TestComplete Work Folder\\Orders.apk";
  var pathOnDevice = "system/app/";
  fileSystemManager.CopyToDevice(pathOnHost, pathOnDevice);

  …

  // Deletes the file from the device
  fileSystemManager.Delete("system/app/Orders.apk");

}

Python

def Test():
  fileSystemManager = Mobile.Device("MyDevice").FileSystemManager

  # Copies a file from the computer to the device
  pathOnHost = "C:\\Work Folders\\TestComplete Work Folder\\Orders.apk"
  pathOnDevice = "system/app/"
  fileSystemManager.CopyToDevice(pathOnHost, pathOnDevice)

  # ...

  # Deletes the file from the device
  fileSystemManager.Delete("system/app/Orders.apk")

VBScript

Sub Test

  Set fileSystemManager = Mobile.Device("MyDevice").FileSystemManager

  ' Copies a file from the computer to the device
  pathOnHost = "C:\Work Folders\TestComplete Work Folder\Orders.apk"
  pathOnDevice = "system/app/"
  Call fileSystemManager.CopyToDevice(pathOnHost, pathOnDevice)

  …

  ' Deletes the file from the device
  Call fileSystemManager.Delete("system/app/Orders.apk")

End Sub

DelphiScript

procedure Test();
var fileSystemManager, pathOnHost, pathOnDevice;
begin

  fileSystemManager := Mobile.Device('MyDevice').FileSystemManager;

  // Copies a file from the computer to the device
  pathOnHost := 'C:\Work Folders\TestComplete Work Folder\Orders.apk';
  pathOnDevice := 'system/app/';
  fileSystemManager.CopyToDevice(pathOnHost, pathOnDevice);

  …

  // Deletes the file from the device
  fileSystemManager.Delete('system/app/Orders.apk');

end;

C++Script, C#Script

function TestDelete()
{

  var fileSystemManager = Mobile["Device"]("MyDevice")["FileSystemManager"];

  // Copies a file from the computer to the device
  var pathOnHost = "C:\\Work Folders\\TestComplete Work Folder\\Orders.apk";
  var pathOnDevice = "system/app/";
  fileSystemManager["CopyToDevice"](pathOnHost, pathOnDevice);

  …

  // Deletes the file from the device
  fileSystemManager["Delete"]("system/app/Orders.apk");

}

See Also

FileSystemManager Object
Testing Android Applications (Legacy)

Highlight search results