aqObject.SaveObjectSnapshotToFile Method

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

Use the aqObject.SaveObjectSnapshotToFile method to save a snapshot of the AObject object to the specified file.

The snapshot contains information on the object’s properties, methods, fields and child objects. To view the saved information, select Load Object Snapshot from the Save/Load Snapshot toolbar. TestComplete will switch to the Object Browser and display the stored information on the object.

The method does not support objects that are not displayed in the object hierarchy in the Object Browser.

For more information on using snapshots, see Creating Snapshots in Object Browser.

Declaration

aqObject.SaveObjectSnapshotToFile(AObject, FileName, SaveRecursive, SaveAllProperties, AdditionalProperties, SaveFields, SaveMethods, Depth)

AObject [in]    Required    Object    
FileName [in]    Required    String    
SaveRecursive [in]    Optional    Boolean Default value: False   
SaveAllProperties [in]    Optional    Boolean Default value: False   
AdditionalProperties [in]    Optional    String Default value: Empty string   
SaveFields [in]    Optional    Boolean Default value: False   
SaveMethods [in]    Optional    Boolean Default value: False   
Depth [in]    Optional    Integer Default value: 2   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

AObject

The object whose properties you want to save.

The object must be displayed in the Object Browser. Otherwise, the method is unable to save the object’s properties and posts an error message to the test log.

FileName

The name of the file where the object’s properties will be saved.

To save the object’s snapshot in the binary format, specify the tcSnapshot extension for the created file. Otherwise, the snapshot will be saved in the XML format. Note that snapshots saved in the binary format occupy much less disk space than those that are saved in the XML format.

SaveRecursive

If it is False (the default value), only the AObject object's properties are saved. If the parameter is True, properties of the object's child objects are saved as well.

SaveAllProperties

If it is False (the default value), only the default object properties are saved. If this parameter is True, all the object properties, except for the indexed properties, are saved.

AdditionalProperties

This parameter only has effect if the SaveAllProperties parameter is False. Use this parameter to specify additional properties that should be saved along with the default properties. You can specify several properties separated by commas or semicolons.

SaveFields

If True, all the fields of the object are saved to the file.

SaveMethods

If True, all the methods of the object are saved to the file.

Depth

The parameter specifies the level of child properties of the selected object to be saved.

Result Value

True if the property values were stored successfully, and False otherwise.

Remarks

If the SaveRecursive parameter is True, the method saves information for child objects of the AObject object. It saves the information according to the other parameters.

When saving child objects, the method goes down the object hierarchy 5 levels down starting from the level of the AObject object. Objects that reside on deeper levels are not saved.

Example

The code below saves a snapshot of the object that corresponds to the Notepad process to a file.

JavaScript, JScript

function SaveObjectToFile()
{

  // Specifies the object to save the information about
  var Obj = Sys.Process("notepad");
  
  // Specifies additional parameters for saving a snapshot
  
  var FileName = "C:\\MyFiles\\ObjectInfo.txt"; // the path to the file the snapshot is saved to
  var SaveRecursive = true; // properties of the object's child objects are saved as well.
  var SaveAllProperties = true;
  var AdditionalProperties = "The file contains the snapshot of an object that corresponds to NOTEPAD.EXE";
  var SaveFields = true;
  var SaveMethods = true;
  
  // Saves the snapshot
  aqObject.SaveObjectSnapshotToFile(Obj, FileName, SaveRecursive, SaveAllProperties, AdditionalProperties, SaveFields, SaveMethods);

}

Python

def SaveObjectToFile():
  # Specifies the object to save the information about 
  Obj = Sys.Process("notepad")
  # Specifies additional parameters for saving a snapshot 
  FileName = "C:\\MyFiles\\ObjectInfo.txt" # the path to the file the snapshot is saved to 
  SaveRecursive = True # properties of the object's child objects are saved as well. 
  SaveAllProperties = True
  AdditionalProperties = "The file contains the snapshot of an object that corresponds to NOTEPAD.EXE"
  SaveFields = True
  SaveMethods = True
  # Saves the snapshot 
  aqObject.SaveObjectSnapshotToFile(Obj, FileName, SaveRecursive, SaveAllProperties, AdditionalProperties, SaveFields, SaveMethods)

VBScript

Sub SaveObjectToFile

  ' Specifies the object to save the information about
  Set Obj = Sys.Process("notepad")
  
  ' Specifies additional parameters for saving a snapshot
  
  FileName = "C:\MyFiles\ObjectInfo.txt" ' the path to the file the snapshot is saved to
  SaveRecursive = true ' properties of the object's child objects are saved as well.
  SaveAllProperties = true
  AdditionalProperties = "The file contains the snapshot of an object that corresponds to NOTEPAD.EXE"
  SaveFields = true
  SaveMethods = true
  
  ' Saves the snapshot
  Call aqObject.SaveObjectSnapshotToFile(Obj, FileName, SaveRecursive, SaveAllProperties, AdditionalProperties, SaveFields, SaveMethods)

End Sub

DelphiScript

function SaveObjectToFile;
var Obj, FileName, SaveRecursive, SaveAllProperties, AdditionalProperties, SaveFields, SaveMethods;
begin

  // Specifies the object to save the information about
  Obj := Sys.Process('notepad');
  
  // Specifies additional parameters for saving a snapshot
  
  FileName := 'C:\MyFiles\ObjectInfo.txt'; // the path to the file the snapshot is saved to
  SaveRecursive := true; // properties of the object's child objects are saved as well.
  SaveAllProperties := true;
  AdditionalProperties := 'The file contains the snapshot of an object that corresponds to NOTEPAD.EXE';
  SaveFields := true;
  SaveMethods := true;
  
  // Saves the snapshot
  aqObject.SaveObjectSnapshotToFile(Obj, FileName, SaveRecursive, SaveAllProperties, AdditionalProperties, SaveFields, SaveMethods);

end;

C++Script, C#Script

function SaveObjectToFile()
{

  // Specifies the object to save the information about
  var Obj = Sys["Process"]("notepad");
  
  // Specifies additional parameters for saving a snapshot
  
  var FileName = "C:\\MyFiles\\ObjectInfo.txt"; // the path to the file the snapshot is saved to
  var SaveRecursive = true; // properties of the object's child objects are saved as well.
  var SaveAllProperties = true;
  var AdditionalProperties = "The file contains the snapshot of an object that corresponds to NOTEPAD.EXE";
  var SaveFields = true;
  var SaveMethods = true;
  
  // Saves the snapshot
  aqObject["SaveObjectSnapshotToFile"]( Obj, FileName, SaveRecursive, SaveAllProperties, AdditionalProperties, SaveFields, SaveMethods );

}

See Also

aqObject Object
Creating Snapshots in Object Browser
About Object Browser

Highlight search results