CopyToDevice Method

Applies to TestComplete 15.69, last modified on November 13, 2024
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 CopyToDevice method to copy a file from your computer to the specified location on the connected Android device.

Declaration

FileSystemManagerObj.CopyToDevice(PathOnTheHost, PathOnTheDevice)

FileSystemManagerObj An expression, variable or parameter that specifies a reference to a FileSystemManager object
PathOnTheHost [in]    Required    String    
PathOnTheDevice [in]    Required    String    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

PathOnTheHost

Specifies the name (with the full path) of the file you want to copy to the device.

If the specified file does not exist on your computer, the method posts a message to the test log informing you about the problem.

PathOnTheDevice

Specifies the location on the Android device to which the file will be copied. Case-sensitive.

Result Value

True if the file has been copied successfully; False otherwise.

Example

The sample code below demonstrates how to access the connected Android device’s file system and copy a file from the local computer to the device:

JavaScript, JScript

function Test()
{

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

  var pathOnDevice = "data/data";
  var pathOnHost = "C:\\TestComplete Work Folder\\Orders.apk";

  fileSystemManager.CopyToDevice(pathOnHost, pathOnDevice);

}

Python

def Test():

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

  pathOnDevice = "data/data"
  pathOnHost = "C:\\TestComplete Work Folder\\Orders.apk"

  fileSystemManager.CopyToDevice(pathOnHost, pathOnDevice)

VBScript

Sub Test

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

  pathOnDevice = "data/data"
  pathOnHost = "C:\TestComplete Work Folder\Orders.apk"

  Call fileSystemManager.CopyToDevice(pathOnHost, pathOnDevice)

End Sub

DelphiScript

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

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

  pathOnDevice := 'data/data';
  pathOnHost := 'C:\TestComplete Work Folder\Orders.apk';

  fileSystemManager.CopyToDevice(pathOnHost, pathOnDevice);

end;

C++Script, C#Script

function Test()
{

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

  var pathOnDevice = "data/data";
  var pathOnHost = "C:\\TestComplete Work Folder\\Orders.apk";

  fileSystemManager["CopyToDevice"](pathOnHost, pathOnDevice);

}

See Also

FileSystemManager Object
Testing Android Applications (Legacy)

Highlight search results