1. Planning Object's Functionality, Methods and Properties

Applies to TestComplete 15.47, last modified on January 20, 2023

In this tutorial, we will create an object that will provide an interface to the operating system’s WMI services. The object’s name is WMI. The object will be a wrapper over the operating system’s SWbemServices object that provides a scripting interface to WMI services. The methods and properties of our WMI object will use methods and properties of the SWbemServices object. In other words, they will be wrappers over the functionality provided by the SWbemServices object. This will make using this object easier to inexperienced testers. For more information, see the description of the SWbemServices object in the MSDN library.

The WMI object that we are going to create will contain the following properties and methods:

Properties
Property Description
Service Read-Only. This property will provide a scripting interface to the operating system’s SWbemServices object.
ComputerName Read-Write. This property will specify the name of the computer that contains the WMI services. Setting the property value should connect the object to the WMI services of the specified computer. The dot (".") means the current computer.
MaxEventCount Read-Write. Specifies the number of latest system events to be logged by the PostEventsInfo method (see below).
Methods
Method Description
ConnectToComputer This method will connect to the WMI services on the specified computer.
CreateProcess This method will launch a new process on the computer.
GetEnvironmentVariable This method will return the value of the specified environment variable.
GetServiceState This method will return the current state of the specified service.
PostDrivesInfo The method will retrieve information about hard drives installed on the computer and write this information to the TestComplete test log.
PostEnvironmentVariableInfo The method will retrieve information about environment variables defined on the computer and write this information to the TestComplete test log.
PostEventsInfo The method will retrieve the latest records from the system event log and save them to the test log. The number of the logged events is specified by the MaxEventCount property (see above).
PostInstalledAppsInfo The method will obtain information about applications installed on the computer and save this information to the test log.
PostProcessorInfo The method will obtain information about the CPU and save this information to the TestComplete test log.
ProcessExists This method will check if the specified process is running on the computer.
RestartComputer This method will restart the computer.
WaitForComputer This method will wait until the specified computer becomes available and the WMI connection to that computer is established.
WaitForProcessExit This method will wait for the specified process to complete.
WaitForServiceState This method will wait for a service to go into the specified state.

In the next topics we will write the code that creates the object, write script code for methods and for the get and set functions of the properties.

Prev     Next

See Also

Script Extensions Tutorials
Script Extensions
WMI Object

Highlight search results