6. Adding Property Definitions to the Description File

Applies to TestComplete 14.71, last modified on April 22, 2021

After creating the code for the object’s properties, we need to add the property definitions to the description file:

  1. Open the C:\My Extension Files\Object Extension\description.xml file in any text or XML editor.

  2. Add the following text to the file:

    XML

    [description.xml]

    <?xml version="1.0" encoding="UTF-8"?>
    <ScriptExtensionGroup>

      <Category Name="Runtime Objects">

        <ScriptExtension Name="WMI Object" Author="SmartBear Software" Version="1.1 test" HomePage="smartbear.com">
          <Script Name="wmiCode.vbs" InitRoutine="Initialize">
            <RuntimeObject Name="WMI">
              <Property Name="ComputerName" GetRoutine="GetComputerName" SetRoutine="SetComputerName">
                The name of the computer that the WMI object works with. A dot (".") stands for the local computer.
              </Property>
              <Property Name="Service" GetRoutine="GetWMIService">
                Returns the WMI service object.
              </Property>
              <Property Name="MaxEventCount" GetRoutine="GetMaxEventCount" SetRoutine="SetMaxEventCount">
                Specifies the maximum number of entries to be retrieved from the system event log.
              </Property>

              <Description>
                Provides access to the WMI service.
              </Description>
            </RuntimeObject>
          </Script>
          <Description>
            Provides scripting interface to WMI objects.
          </Description>
        </ScriptExtension>

      </Category>

    </ScriptExtensionGroup>

  3. Save the changes.

As you can see, we added a new InitRoutine attribute to the Script element and a number of child Property elements to the RuntimeObject element.

The InitRoutine attribute of the Script element specifies the name of the routine that contains initialization code. It will be executed when the unit is loaded in memory. As you remember, this routine is called Initialize:

XML

[description.xml]
 

...
<Script Name="wmiCode.vbs" InitRoutine="Initialize">
  <RuntimeObject Name = "WMI">
    ...
  </RuntimeObject>
</Script>

The Script element also has the FinalRoutine attribute that specifies the name of the finalization routine. This attribute is not used in our tutorial. For information about it, see the description of the Script element.

To define the properties, we added three child Property elements to the RuntimeObject element (one element per each property of the object). Let’s look at the element’s attributes:

XML

[description.xml]
 

...
<Property Name="MaxEventCount" GetRoutine="GetMaxEventCount" SetRoutine="SetMaxEventCount">Specifies the maximum number of entries to be retrieved from the system's event log.</Property>
...

The Name attribute specifies the property name that will be used to address the property. This name must be a valid identifier in any scripting language supported by TestComplete. The easiest way to meet this requirement is to use a name that starts with a letter and contains only letters, digits and underscore characters. The property name must also be unique among the other methods and properties of the object.

The GetRoutine and SetRoutine attributes specify the get and set script functions for the property. In the example above, these functions are GetMaxEventCount and SetMaxEventCount. As you remember, we created them in the previous step.

The contents of the Property element is used as the property’s description and is shown in the Code Completion window when a user chooses the property in it.

For detailed information about elements and attributes that are used in the description files, see topics of the Script Extension Files section.

Prev     Next

See Also

Structure of the Description File

Highlight search results