TestComplete Tutorial 18 - Creating Snapshots in Object Browser
TestComplete allows you to store snapshots of your tested application.
A snapshot contains complete information about properties, fields and/or methods of an object that you selected and, optionally, of all of its child objects.
Creating Snapshots
To create a snapshot from the Object Browser -
- Select the desired object in the object hierarchy displayed in the Object Browser.
- Click the Save Object Snapshot button on the Save/Load Snapshots toolbar. If the toolbar is hidden, right-click somewhere within the TestComplete toolbar or menu area and select Save/Load Snapshots from the pop-up list.
- This will open the Save Object Snapshot dialog. In the dialog specify the snapshot file name and object information the snapshot will contain.
- Click OK.
To create a snapshot from tests -
- Use the
aqObject.SaveObjectSnapshotToFile
method that saves the object snapshot to the specified file. The method takes parameters that specify the object for which you want to create a snapshot, the snapshot file name and information the snapshot will contain. - To call the method from keyword tests, use the Call Object Method, Run Code Snippet or Run Script Routine operations.
The following code saves information on the object that corresponds to the Notepad process to a file:
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.tcSnapshot"; // 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;
// Saves the snapshot
aqObject.SaveObjectSnapshotToFile(Obj, FileName, SaveRecursive, SaveAllProperties);
}
Note -
- Snapshots can be created only for objects that are displayed in the object hierarchy in the Object Browser.
- To close the currently opened snapshot and restore the default view, click the Show Default Object Tree button.
Loading Snapshots
- Click the Load Object Snapshot button on the Save/Load Snapshots toolbar.
- In the ensuing Load Object dialog, browse for the needed snapshot file.
- The Object Browser will display the object hierarchy stored in the selected snapshot as well as object properties, fields, values and methods. The information you see is the same as if you dealt with “live” objects.
Comments
Post a Comment