Tips for Working with QuickTest Add-ins

QuickTest add-ins help you to create and run components on applications in a variety of development environments. After you load an add-in, you can record and run components on applications in the corresponding development environment, similar to the way you do with any other application.

To take full advantage of QuickTest add-in capabilities, keep the following in mind when designing components using QuickTest add-ins:

  • You must install and load an add-in to enable QuickTest to recognize objects from the corresponding environment. To load an add-in, select the add-in from the Add-in Manager dialog box that opens when you start QuickTest.
  • If the Add-in Manager does not open when you start QuickTest, click the Options button or choose Tools > Options and click the General tab. Select the Display Add-in Manager on startup check box and click OK. Restart QuickTest.
  • To maximize performance and object identification reliability, load only the add-ins you need. For example, if you want to test a process that spans a Web application and a .NET application, load only the Web and .NET Add-ins. Do not load all add-ins unless you need to work with all of them.
  • You can view the list of add-ins that are currently installed or loaded by choosing Help > About QuickTest Professional. The dialog box displays a list of all add-ins installed on your computer. A check mark indicates that the add-in is currently loaded.
  • You can view license details for all currently loaded licensed add-ins by clicking License in the About QuickTest Professional dialog box (Help > About QuickTest Professional).
    • For seat licenses, the category for each license is displayed. The license category may be Demo, Permanent, Commuter, or Time-Limited. For Demo, Commuter (used with concurrent licenses), and Time-Limited QuickTest seat licenses, the number of days and hours remaining until the license expires is also displayed.

Working with QuickTest Add-Ins

You can install the QuickTest built-in add-ins (Web, ActiveX, Visual Basic) when you install QuickTest Professional, or you can install the QuickTest built-in add-ins at a later time by running the installation again. Add-ins that are available separately from the QuickTest Professional built-in installation are referred to as external add-ins.

ActiveX Add-in—You can use the built-in ActiveX Add-in to test ActiveX controls. You can create and run components on these controls, as well as check their properties. You create and run components on ActiveX controls in much the same way as you do for standard Windows applications.

For information on supported ActiveX controls and versions, refer to the QuickTest Professional Readme.

Visual Basic Add-in—You can use the built-in Visual Basic Add-in to test Visual Basic applications. You can create and run components on these controls, as well as check their properties. You create and run components on Visual Basic applications in much the same way as you do for standard Windows applications.

To test Visual Basic .NET Windows Forms applications, you must install and load the .NET Add-in. Note that the .NET Add-in is an external add-in and is not included with your core QuickTest installation. To purchase this add-in, contact your QuickTest supplier or Mercury Customer Support.

Web Add-in—You can use the built-in Web Add-in to test your Web pages and applications. You can test Web objects such as hyperlinks, images, image maps, and Viewlink objects. For more information on using the Web Add-in, see Working with the Web Add-in.

When QuickTest opens, you can choose which of the installed add-ins you want to load using the QuickTest Professional - Add-In Manager dialog box.

If you choose to load an installed add-in, QuickTest recognizes the objects you record on the corresponding environment and enables you to work with the appropriate methods, properties, and specialized options.

Each external add-in requires a seat or concurrent license code. You install a seat add-in license on your computer using the Add-in Manager dialog box. You install a concurrent add-in license on the Mercury Functional Testing Concurrent License Server computer.

Using the QuickTest Automation Reference

The QuickTest Automation Reference is a Help file that provides detailed descriptions, syntax information, and examples for the objects, methods, and properties in the QuickTest automation object model.

You can open the QuickTest Automation Reference from the:

  • QuickTest program folder (Start > Programs > QuickTest Professional > Documentation > QuickTest Automation Reference)
  • Main QuickTest Help (Help > QuickTest Professional Help > QuickTest Advanced References > QuickTest Automation)

The QuickTest Automation Reference contains an Object Model Diagram page that shows all objects in the QuickTest automation object model, and their relationship to one another. You can click any object to view more information about that object.

The Help topic for each automation object includes a list and description of methods and properties associated with that object. Method and property Help topics include detailed description, syntax, return value or property type, and possible values information. Most topics also include one or more examples.

Generating Automation Scripts

The Properties tab of the Test Settings dialog box, the General tab of the Options dialog box, and the Object Identification dialog box each contain a Generate Script button. Clicking this button generates an automation script file (.vbs) containing the current settings from the corresponding dialog box.

You can run the generated script as is to open QuickTest with the exact configuration of the QuickTest application that generated the script, or you can copy and paste selected lines from the generated files into your own automation script.

For example, the generated script for the Options dialog box may look something like this:

Dim App 'As Application

Set App = CreateObject("QuickTest.Application")

App.Launch

App.Visible = True

App.Options.DisableVORecognition = False

App.Options.AutoGenerateWith = False

App.Options.WithGenerationLevel = 2

App.Options.TimeToActivateWinAfterPoint = 500

...

...

App.Options.WindowsApps.NonUniqueListItemRecordMode = "ByName"

App.Options.WindowsApps.RecordOwnerDrawnButtonAs = "PushButtons"

App.Folders.RemoveAll

For more information on the Generate Script button and for information on the options available in the Options, Object Identification, and Test Settings dialog boxes, refer to the QuickTest Professional User's Guide.

Running Automation Scripts on a Remote Computer

By default, when you create an Application object in your automation script, it is created on your local computer (using your local copy of QuickTest Professional). You also have the option to run automation scripts on a remote QuickTest computer. To do so, you must:

  • Ensure that the Distributed COM (DCOM) Configuration Properties of the remote computer are set to allow you to run QuickTest Professional Automation from your computer.
  • Specify the remote computer in the automation script in the application creation script line, for example, using the optional location argument in the VBScript CreateObject function.
Setting DCOM Configuration Properties on the Remote Computer

QuickTest automation enables QuickTest to act as a COM automation server. Therefore, to run a QuickTest automation script on a remote computer, you must ensure that the DCOM configuration properties for that computer give you the proper permissions to launch and configure the QuickTest COM server.

The procedure below describes the steps you need to perform on the remote computer to enable your automation script to run on that computer. Note that the DCOM Configuration Property the appearance and names of the dialog boxes and options mentioned here may vary depending on the computer's operating system.

To enable automation scripts to access a QuickTest computer remotely:

  1. On the computer where you want to run the automation script, choose Start > Run. The Run dialog box opens.
  2. Enter dcomcnfg and click OK. The Distributed COM Configuration Properties dialog box or the Component Services window opens (depending on your operating system) and displays the list of COM applications available on the computer.
  3. Select QuickTest Professional Automation from the list and open the Properties dialog box for the application. (Click the Properties button or right-click and choose Properties, depending on your operating system.)
  4. In the QuickTest Professional Automation Properties dialog box, click the Security tab.
  5. In the launch permissions section, choose the custom option and click Edit.
  6. Use the Add and Remove options to select the network users or groups for which you want to allow or deny permission to launch QuickTest Professional via an automation script. When you are finished, click OK to save your settings.
  7. Repeat steps 5 and 6 for the configuration permissions section to select the users or groups who can modify QuickTest Professional configuration options via an automation script.
  8. In the QuickTest Professional Automation Properties dialog box, click the Identity tab and select the interactive user option.
  9. Click OK to save the QuickTest Professional Automation Properties settings.
  10. Click OK to close the Distributed COM Configuration Properties dialog box or the Component Services window.
Creating an Application Object on a Remote Computer

Once you have set the necessary DCOM Configuration settings for a remote computer, you can specify that computer in your automation script.

In VBScript, you do this by specifying the computer name as the optional location argument of the CreateObject function. The computer name should be the same as the computer name portion of a share name. For example, to run an automation script on a computer called MyServer, you could write:

Dim qtApp

Set qtApp = CreateObject("QuickTest.Application", "MyServer")

For information on the syntax for specifying the remote computer in another language you are using, refer to the documentation included with your development environment or to general documentation for the programming language.

Structuring Your Script

You may perform a few operations before you start QuickTest such as retrieving the associated add-ins for a test or component, loading add-ins, and instructing QuickTest to open in visible mode.

After you perform these preparatory steps, if QuickTest is not already open on the computer, you can open QuickTest using the Application.Launch method. Most operations in your automation script are performed after the Launch method.

When you finish performing the necessary operations, or you want to perform operations that require closing and restarting QuickTest, such as changing the set of loaded add-ins, use the Application.Quit method

Creating the Application Object

The procedure for creating the application object differs slightly from language to language. Below are some examples for creating the QuickTest Application object and starting QuickTest in visible mode, using different programming languages.

Visual Basic

The example below can be used only after setting a reference to the type library. If you are not working in a development environment that allows referencing type libraries create the Application object as described for VBScript below.

Dim qtApp As QuickTest.Application ' Declare the application object

Set qtApp = New QuickTest.Application ' Create the application object

qtApp.Launch ' Start QuickTest

qtApp.Visible = True ' Make it visible

VBScript

Dim qtApp

Set qtApp = CreateObject("QuickTest.Application") ' Create the application object

qtApp.Launch 'Start QuickTest

qtApp.Visible = True ' Make it visible

JavaScript

var qtApp = new ActiveXObject("QuickTest.Application"); // Create the application object

qtApp.Launch(); // Start QuickTest

qtApp.Visible = true // Make it visible

Visual C++

#import "QTObjectModel.dll" // Import the type library

QuickTest::_ApplicationPtr spApp; // Declare the application pointer

spApp.CreateInstance("QuickTest.Application"); // Create the application object

spApp->Launch();// Launch the application

spApp->Visible = VARIANT_TRUE; // Make it visible

Deciding When to Use QuickTest Automation Scripts

Creating a useful QuickTest automation script requires planning, design time, and testing. You must always weigh the initial investment with the time and human-resource savings you gain from automating potentially long or tedious tasks.

Any QuickTest operation that you must perform many times in a row or must perform on a regular basis is a good candidate for a QuickTest automation script.

The following are just a few examples of useful QuickTest automation scripts:

  • Initialization scripts. You can write a script that automatically starts QuickTest and configures the options and the settings required for recording on a specific environment.
  • Maintaining your tests or components. You can write a script that iterates over your collection of tests and components to accomplish a certain goal. For example:
    • Updating values. You can write a script that opens each test or component with the proper add-ins, runs it in update run mode against an updated application, and saves it when you want to update the values in all of your tests and components to match the updated values in your application.
    • Applying new options to existing tests or components. When you upgrade to a new version of QuickTest, you may find that the new version offers certain options that you want to apply to your existing tests and components. You can write a script that opens each existing test and component, sets values for the new options, then saves and closes it.
  • Calling QuickTest from other applications. You can design your own applications with options or controls that run QuickTest automation scripts. For example, you could create a Web form or simple Windows interface from which a product manager could schedule QuickTest runs, even if the manager is not familiar with QuickTest.

Exporting Local Objects to an Object Repository

You can export all of the objects contained in a component's local object repository to a new shared object repository in the file system or to a Quality Center project (if QuickTest is connected to Quality Center). This enables you to make the local objects accessible to other components. You export local objects to a new shared object repository using the Object Repository window.

Note: If your local object repository contains objects with parameterized property values, when you export these objects to a shared object repository the parameterized values become repository parameters that are mapped to their previous values. For example, if a local object was parameterized to use a component parameter, when you export the local object to a shared object repository it will be modified to a repository parameter that is mapped to a component parameter with the same value.

Tip: After you export the local objects, you can use the Object Repository Merge Tool to merge the shared object repository containing the exported objects with another shared object repository.

To export local objects to a new shared object repository:

  1. Open the component that has the local objects you want to export.
  2. Make sure that the Object Repository window is open.
  3. Choose File > Export Local Objects. The Export Object Repository dialog box opens.

Note: If you are connected to Quality Center, the dialog box that opens is different from the standard file system dialog box. You can switch between the two dialog box versions by clicking the File System and Quality Center buttons in the Export Object Repository dialog box.

  1. Select the location in which to save the file, specify the file or attachment name, and click Save or OK (depending on whether you are saving it to the file system or a Quality Center project).

The object repository is exported to the specified shared object repository (a file with a .tsr extension). You can now use the new shared object repository like any other shared object repository.

Modifying Test Object Properties at Runtime

You can modify the properties of the temporary version of the object during the run session without affecting the permanent values in the object repository by adding a SetTOProperty statement in a user-defined function.

Use the following syntax for the SetTOProperty method:

Object(description).SetTOProperty Property, Value

Working with Test Objects During a Run Session

The first time QuickTest encounters an object during a run session, it creates a temporary version of the test object for that run session. QuickTest uses the object description to create this temporary version of the object. For the remainder of the component, QuickTest refers to the temporary version of the test object rather than to the test object in the object repository.

Note: The Object Repository window is read-only during record and run sessions.

There are several ways to modify test object properties. Choose the way that best suits your needs:

  • You can manually change a test object property value to match a new static property of an object in your application. For
  • You can create a function (operation) that uses the SetTOProperty method to modify test object properties during a run session without changing the property values in the object repository.
  • You can modify the set of properties that QuickTest uses to identify the object, so that it will be able to identify an object even when some of its properties change.
  • You can use regular expressions to identify an object based on conditions or patterns you define.

Moving Objects in the Object Repository

You can copy, paste, and move objects in the local object repository using the Object Repository window, and copy, paste, and move objects both within a shared object repository and between shared object repositories using the Object Repository Manager. However, you cannot modify the root node of an object repository. You can also copy objects from a shared object repository to the local object repository to modify them locally.

You can move an object to a different location within an object repository by dragging it up or down the tree and dropping it at the required location. You can copy an object to a different location within an object repository by pressing the Ctrl key while dragging the object and dropping it at the required location in the tree.

When you drag an object, by default, any child objects are also moved or copied with it. If you want to move or copy an object without its child objects, you can drag it using the right mouse button. When you drop the object at the required location, you can choose whether to drop it with or without its children.

You can cut, copy, and paste objects within an object repository using the corresponding toolbar buttons or in the Edit menu. In the Object Repository Manager, you can also cut, copy, and paste objects between shared object repositories. When you cut, copy, and paste objects, the operation is performed also on the child objects of the selected object, if any.

In the Object Repository window, when you copy, paste, and move objects from a shared object repository associated with the component, the objects are copied, pasted, or moved to the local object repository of the component.

You cannot copy, paste, or move objects that have unmapped repository parameters from a shared object repository to the local object repository. If you copy, paste, or move an object from a shared object repository to the local object repository and the object or one of its parent objects are parameterized using one or more repository parameters, the repository parameter values are converted when you copy, paste, or move the object. For example, if the repository parameter is mapped to a local parameter, the property is parameterized using a local parameter. If the value is a constant value, the property receives the same constant value.

In the Object Repository Manager, you can copy an object from one shared object repository to another by opening both shared object repositories and dragging the object from one window and dropping it at the required location in the other window. You can move an object from one shared object repository to another by opening both shared object repositories pressing the Ctrl key while dragging the object from one window and dropping it at the required location in the other window. Note that moving an object removes it from one shared object repository and adds it to another.

Note: You can use the Edit > Undo and Edit > Redo options or Undo and Redo buttons to cancel or repeat your changes. When you save the object repository, you cannot undo and redo operations that were performed before the save operation.

When copying, pasting, or moving objects, consider the following:

  • If you change the object hierarchy, ensure that the new hierarchy is a valid recorded hierarchy.
  • If you paste or move an object to a different hierarchical level, you can choose whether to copy all objects up to the shared parent object (in the message displayed when you perform such an operation).
  • If you move an object to its immediate parent, QuickTest creates a copy of the object (renamed with an incremental suffix) and pastes it as a sibling of the original object.
  • If you cut or copy an object, and then paste it on its parent object, QuickTest creates copy of the object (renamed with an incremental suffix) and inserts it at the same level as the original object.
  • You cannot move an object to any of its descendants.
  • You cannot copy or move an object to be a child of a bottom-level object (an object that cannot contain a child object) in the object hierarchy.

Note: WinMenu objects can be either parent or bottom-level objects.

Adding Properties to a Test Object Description

You can add to the list of properties that QuickTest uses to identify an object. For each object class, QuickTest has a default property set that it uses for the object description for a particular object. You can use the Add Properties dialog box to change the properties that are included in the object description. You can do this for objects in the local object repository using the Object Repository window or Object Properties dialog box, and for objects in the shared object repository using the Object Repository Manager.

Note: You can also add any valid test object property to a test object description, even if it does not appear in the Add Properties dialog box..

Adding to the list of properties is useful when you want to create and run components on an object that changes dynamically. An object may change dynamically if it is frequently updated, or if its property values are set using dynamic content (for example, from a database).

You can also change the properties that identify an object if you want to reference objects using properties that were not automatically learned while recording. For example, suppose you are testing a Web site that contains an archive of newsletters. The archive page includes a hypertext link to the current newsletter and additional hypertext links to all past newsletters. The text in the first hypertext link on the page changes as the current newsletter changes, but it always links to a page called current.html. Suppose you want to create a step in your component in which you always click the first hypertext link in your archive page. Since the news is always changing, the text in the hypertext link keeps changing. You need to modify how QuickTest identifies this hypertext link so that it can continue to find it.

The default properties for a Link object (hypertext link) are text and HTML tag. The text property is the text inside the link. The HTML tag property is always A, which indicates a link.

You can modify the default properties for a hypertext link for the object that was recorded so that you can identify it by its destination page, rather than by the text in the link. You can use the "href" property to check the destination page instead of using the "text" property to check the link by the text in the link.

Tip: You can use the Object Spy at any time to view run-time or test object properties and values of the objects in the application you are testing. You open the Object Spy by choosing Tools > Object Spy or clicking the Object Spy toolbar button

Note: You can also modify the set of properties that QuickTest learns when it records objects from a particular object class using the Object Identification dialog box. Such a change generally affects only objects that you learn or record after you make the change. You can also apply the changes you make in the Object Identification dialog box to the descriptions of all objects in an existing component using the Update Run Mode option.

To add properties to a test object description:

  1. In the object repository tree, select the test object whose description you want to modify.
  2. In the Test object details area, click the Add description properties button .

Tip: For an object in the local object repository, you can also select the required test object and choose Edit > Step Properties > Object Properties, click the Add description properties button , and then perform the following steps in the Add Properties dialog box.

The Add Properties dialog box opens listing the properties that can be used to identify the object (properties that are not already part of the test object description). The value for each property is displayed in the Value column.

Notes: Values for all properties are displayed only if the application that contains the object is currently open. If the application is closed, only values for properties that were part of the object description when the object was learned are shown.

You can resize the Add Properties dialog box to enable you to view long property values.

You can click the Define new property button to add valid test object properties to this properties list..

  1. Select one or more properties to add to the test object description and click OK. You can also double-click a property to add it to the test object description. You can type the first letters of a property to highlight the first property in the list that matches the pattern.

Tip: After you add a new property to the object description, you can modify its value

QuickTest Automation Object Model

Essentially all configuration and run functionality provided via the QuickTest interface is in some way represented in the QuickTest automation object model via objects, methods, and properties. Although a one-on-one comparison cannot always be made, most dialog boxes in QuickTest have a corresponding automation object, most options in dialog boxes can be set and/or retrieved using the corresponding object property, and most menu commands and other operations have corresponding automation methods.

You can use the objects, methods, and properties exposed by the QuickTest automation object model, along with standard programming elements such as loops and conditional statements to design your script.

Automation scripts are especially useful for performing the same tasks multiple times or on multiple tests or components, or quickly configuring QuickTest according to your needs for a particular environment or application.

For example, you can create and run an automation script from Microsoft Visual Basic that loads the required add-ins for a test or component, starts QuickTest in visible mode, opens the test or component, configures settings that correspond to those in the Options, Test or Business Component Settings, and Record and Run Settings dialog boxes, runs the test or component, and saves the test or component.

You can then add a simple loop to your script so that your single script can perform the operations described above for multiple tests or components.

You can also create an initialization script that opens QuickTest with specific configuration settings. You can then instruct all of your testers to open QuickTest using this automation script to ensure that all of your testers are always working with the same configuration.

What is Automation

Automation is a Microsoft technology that makes it possible to access software objects inside one application from other applications. These objects can be easily created and manipulated using a scripting or programming language such as VBScript or VC++. Automation enables you to control the functionality of an application programmatically.

An object model is a structural representation of software objects (classes) that comprise the implementation of a system or application. An object model defines a set of classes and interfaces, together with their properties, methods and events, and their relationships.