Stage 1: Preparing the Infrastructure—Creating a Basic Testing Agent

The first stage of developing a Testing Agent is creating the infrastructure. This section describes how the COM object for the QuickID application's Testing Agent was created and how it was set up to implement the main Testing Extensibility interface: ITestable.

Creating the COM Object

The COM object was created using the Microsoft Visual Studio wizard, accessed by selecting Project > Add Class. In the left pane, choose ATL. In the right pane, select ATL Simple Object and click Add. The following details were entered to create the new ATL Simple Object class:

  • Short Name: CTEASampleTestableImp

  • Class: CTEASampleTestableImp

  • Coclass: TEASampleTestableImp

  • Interface: ITEASampleTestable

  • ProgID: TEASample.TEASampleTestableImp

    The wizard generated the CTEASampleModule class (for the ATL support for the project) and the following files:

    • TEASampleTestableImp.h

    • TEASampleTestableImp.cpp

    • TEASampleTestableImp.rgs

    • TEASample.idl

    These files are located in the <UFT One Testing Extensibility installation folder>\samples\QuickID\<Visual Studio version>\src folder)

Back to top

Making the COM Object a Testing Agent

For the COM object to become a Testing Agent and enable UFT One to recognize and operate on objects in your environment, the COM object must implement interfaces defined in AutInterface.idl, located in <UFT One Testing Extensibility SDK installation folder>\SDK\Ifs.

The most important interface in the UFT Extensibility Agent type library is ITestable. This interface defines the methods that the Testing Agent must implement to support the basic UFT One abilities. The ITestable interface is therefore considered mandatory in the development of the Testing Agent.

In the initial development stages, the QuickID Testing Agent was designed to implement only the ITestable interface. (In the later stages of developing the Testing Agent, Stage 7: Implementing Support for Recording and Stage 8: Implementing Support for the Object Spy, additional interfaces are implemented.)

For this purpose, the UFT Extensibility Agent type library was imported and the Testing Agent class was defined to inherit from the ITestable interface, as follows:

  1. Importing the UFT Extensibility Agent type library

    In the TEASample.idl file, the line: importlib("AutInterface.tlb"); was added to the TEASampleLib type library definition.

    The AutInterface.tlb file imported by the type library is located in the <UFT One Testing Extensibility SDK installation folder>\SDK\Ifs folder.

  2. Inheriting from the ITestable interface

    The following steps were performed to define that the Testing Agent implements the ITestable interface:

    1. In the TEASample.idl file, the coclass TEASampleTestableImp definition was modified to indicate that it implements the ITestable interface.

    2. In the TEASampleTestableImp.h file:

      • The following line was added to the CTEASampleTestableImp class inheritance list:

        public IDispatchImpl<ITestable, &__uuidof(ITestable), &LIBID_AutInterface>
        
      • The following line was added to the CTEASampleTestableImp class' COM Map:

        COM_INTERFACE_ENTRY(ITestable)
        
      • All of the methods in the ITestable interface were declared members of the CTEASampleTestableImp class.

    3. In the TEASampleTestableImp.cpp file, all of the ITestable methods were added with a default implementation returning E_NOTIMPL.

Back to top