Stage 2: Introducing the Environment to UFT One

After creating the infrastructure for the Testing Agent, the next stage is to implement the GetTestingEnvironment method to introduce the environment to UFT One. UFT One calls the GetTestingEnvironment method when it loads the Testing Agent.

In this stage of the QuickID Testing Agent development, an XML definition of the environment that the QuickID application represents was created, and the GetTestingEnvironment method was implemented to return this XML definition.

Defining the Environment

Before implementing the Testing Agent, the environment that the Testing Agent needs to support must be clearly defined. For example, this includes defining the test objects relevant for the environment, icons to represent these test objects in UFT One, the test object identification properties, and the operations that can be performed on each test object. For information on defining a testing environment, see Planning Your UFT One Testing Agent.

UFT One requires that the environment definition be provided in XML format according to the Testing Environment Schema. It is convenient to create an XML file that contains the environment definition in the correct format and to design GetTestingEnvironment to load this file and return it to UFT One as an XML string.

The XML environment definition that was created for the QuickID is stored in the TEASampleEnvironment.xml file, located in the <UFT One Testing Extensibilityinstallation folder>\samples\QuickID\<Visual Studio version>\dat folder. Open the file and examine its contents:

Each classInfo element defines a test object class. The following test object classes are defined for the QuickID:

  • TEASampleApplication. The UFT One test object that represents the application itself.

  • TEASampleNameEdit. The UFT One test object that represents the text box for entering the user's name.

  • TEASampleCitySelector. The UFT One test object that represents the drop-down menu for selecting the city.

Each test object class definition includes test object methods and identification properties. For example:

  • The TEASampleCitySelector test object class definition includes a Select test object method. This method receives the name of the city to select (out of a predefined list) and when the method runs, it selects the city in the application.

  • The TEASampleApplication test object class definition includes a DisplayDetails test object method. When this test object method runs, it simulates the operation of pressing the OK button on the application, displaying the sentence:

    Your name is <entered name>. You live in <selected city>.

    This test object method demonstrates the power and purpose of UFT One Testing Extensibility. The primitive operation of pressing the OK button in the application is represented in the test by a more meaningful logical operation.

  • The TEASampleCitySelector test object class definition includes a selectedcity test object identification property. The value of this property is the index of the selected city within the list of available cities. If the Testing Agent is loaded, UFT One displays this test object identification property when you point the Object Spy pointer to the TEASampleCitySelector test object.

Back to top

Implementing the GetTestingEnvironment() Method

When UFT One loads a Testing Agent, it calls the GetTestingEnvironment method to return the XML environment definition. UFT One uses the information returned by this method to build the collection of test objects to use for this environment.

For the QuickID Testing Agent, the method CTEASampleTestableImp::GetTestingEnvironment (in the TEASampleTestableImp.cpp file) was implemented to load the TEASampleEnvironment.xml file described above and return its content.

Back to top