DeleteProperty Method

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

The object-driven testing (ODT) functionality is deprecated. Do not use it to create new tests. It will be removed from the product in one of the future releases. As an alternative, you can create custom classes in your scripts. For more information, see Alternatives to the ODT functionality.

Description

Use the Object.DeleteProperty method to delete a property from the Object object.

Declaration

ObjectObj.DeleteProperty(Name)

ObjectObj An expression, variable or parameter that specifies a reference to an Object object
Name [in]    Required    String    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Name

Specifies the name of the property to be deleted. If the object does not contain a property with the specified name, an error occurs.

Result Value

None.

Remarks

Note that this method cannot delete a property that was declared in the class on which the Object_Obj object is based. If you try to delete such a property, an error will occur. You can delete only properties that were added to the Object_Obj object by one of the following methods: Object.AddProperty, Object.AddPropOfArrayType, Object.AddPropOfClassType. To delete a property that was declared in a class, use the Class.DeleteProperty method.

Example

The following code snippet declares a new class, creates an object based on the declared class and adds a property to the object. After the object’s properties are processed with the Run method, the added property is deleted.

JavaScript, JScript

function ObjectSample()
{
ODT.Data.Clear();
ODT.Classes.Clear();
  var NewClass, MyObject;
  // Declares a new class
  NewClass = ODT.Classes.Declare("NewClass");
  // Adds properties and methods to the new class
  NewClass.AddProperty("ClassProperty1", 10);
  NewClass.AddProperty("ClassProperty2", "Sample");

  // Creates an object based on the declared class
  MyObject = ODT.Classes.New("NewClass");

  // Adds a property to the object
  MyObject.AddProperty("ObjectProperty", true);

  // Processes the object’s properties
  MyObject.Run();

  // Deletes the property added to the object
  MyObject.DeleteProperty("ObjectProperty");

}

VBScript

Sub ObjectSample

ODT.Data.Clear
ODT.Classes.Clear
  ' Declares a new class
  Set NewClass = ODT.Classes.Declare("NewClass")
  ' Adds properties and methods to the new class
  Call NewClass.AddProperty("ClassProperty1", 10)
  Call NewClass.AddProperty("ClassProperty2", "Sample")

  ' Creates an object based on the declared class
  Set MyObject = ODT.Classes.New("NewClass")

  ' Adds a property to the object
  Call MyObject.AddProperty("ObjectProperty", true)

  ' Processes the object’s properties
  MyObject.Run

  ' Deletes the property added to the object
  MyObject.DeleteProperty("ObjectProperty")

End Sub

DelphiScript

procedure ObjectSample();
var NewClass, MyObject;
begin
ODT.Data.Clear();
ODT.Classes.Clear();
  // Declares a new class
  NewClass := ODT.Classes.Declare('NewClass');
  // Adds properties and methods to the new class
  NewClass.AddProperty('ClassProperty1', 10);
  NewClass.AddProperty('ClassProperty2', 'Sample');

  // Creates an object based on the declared class
  MyObject := ODT.Classes.New('NewClass');

  // Adds a property to the object
  MyObject.AddProperty('ObjectProperty', true);

  // Processes the object’s properties
  MyObject.Run();

  // Deletes the property added to the object
  MyObject.DeleteProperty('ObjectProperty');

end;

C++Script, C#Script

function ObjectSample()
{
ODT["Data"]["Clear"]();
ODT["Classes"]["Clear"]();
  var NewClass, MyObject;
  // Declares a new class
  NewClass = ODT["Classes"]["Declare"]("NewClass");
  // Adds properties and methods to the new class
  NewClass["AddProperty"]("ClassProperty1", 10);
  NewClass["AddProperty"]("ClassProperty2", "Sample");

  // Creates an object based on the declared class
  MyObject = ODT["Classes"]["New"]("NewClass");

  // Adds a property to the object
  MyObject["AddProperty"]("ObjectProperty", true);

  // Processes the object’s properties
  MyObject["Run"]();

  // Deletes the property added to the object
  MyObject["DeleteProperty"]("ObjectProperty");

}

See Also

DeleteProperty Method
Properties Property
AddProperty Method
DeleteMethod Method
Property Object

Highlight search results