Wednesday 8 May 2013

Extensibility in QTP


Extensibility in QTP

Quick Test Professional add-in Extensibility enables you to extend the relevant quick test add-in to support third-party and custom controls that are not supported out of the box.

Automation tools like QTP have been very helpful for the testing techniques like regressing the application. QTP is such a tool which can identify the objects of the application in its own way (through Automation Object Model) and can replicate the manual steps of entering, retrieving values and performing some actions on the application. 

QTP performs above mentioned steps by the way it recognizes Objects in the application. It identifies these objects with the help of Automation Object Model.
QTP generally has this AOM or AOM can be shipped in the form of an addin along with the QTP tool.

Sometimes it’s not possible for HP (QTP is tool provided by Hewlett Packard) to provide the complete Automation Object Model for all kinds of applications. 
Building of such kind of Automation Object Model can be achieved by writing Extensible Code.

Extensibility: Quick Test Professional Extensibility enables you to provide high-level support for third-party and custom controls that are not supported out-of-the-box by the Quick Test Professional.


When to use Extensibility?

Extensibility can be used in case any of the below mentioned points holds correct for the application w.r.t. QTP.
  • QTP might recognize the control using a test object class that does not fit your needs. Or the object identification properties and test object methods are not sufficient. Extensibility can be used to map the custom class to another existing test object class or to a new test object class.
  • The test object class mapped to the control might be satisfactory, but one would like to customize the behavior of certain test object methods or identification properties. Extensibility can be used to override the default implementation of these properties and methods with your own custom implementation.
  • Sometimes the test object names QTP generates for all controls of a certain Java class are identical (except for a unique counter) or that the name used for the control does not clearly indicate the object it represents. Extensibility can be used to modify how QTP names test objects for that Java class.
  • QTP may identify individual sub-controls within the custom control, but not properly identify the main control. 
  • QTP may not record a step at all when an action performed on a control
  • QTP’s Virtual Object does not serve the requirement.

Key Technologies Supported by Extensibility-

  Web 2.0 Toolkit
ASP.NET
AJAX (Asynchronous JavaScript And XML)
Dojo
Yahoo UI
GWT (Google Web Toolkit)
  AWT (Abstract Window Toolkit)
  JFC11 (Java Foundation Classes - Swing)
  SWT (Standard Widget Toolkit)
  Delphi
  Silverlight
  WPF


How to Use Java Extensibility

Pre-Requisite-

Following software and add-ins needs to be installed on the machine where Java Extensibility code has to be written for an application:

1-Eclipse:
Eclipse is a multi-language software development environment comprising an integrated development environment (IDE) and an extensible plug-in system. It is written mostly in Java.

2-QTP:
HP Quick Test Professional is automated testing software designed for testing various software applications and environments. It performs functional and regression testing through a user interface such as a native GUI or web interface.

3-QTP Java Add-in:
QTP add-ins provides support for Java. QTP and the QTP add-ins are packaged together in HP Functional Testing software. However, license for this Java adding needs to be purchased from HP.

4-QTP Java Add-in Extensibility SDK:
The SDK supplies a plug-in for the Eclipse IDE that provides wizards and commands to simplify the process of creating custom support. This SDK is provided by the QTP


Setting Up the Extensibility Toolkit-

Following are the steps needed to follow for setting up the Extensibility toolkit:

1.Creating the Eclipse workspace
A project workspace needs to be defined before creating a new project in Eclipse. The workspace can be defined in 2 ways:

      I. Eclipse by default asks for the workspace path as shown below.



      II.      Workspace can also be created by navigating to File->SwitchWorkspace->Others





2.Creating the Java Add-in Extensible Project in Eclipse
Now create a QTP Extensible project in the Eclipse Workspace. Steps for creating this project are as follows:
     I.      Go to New ->Project. Select the option Quick Test Java Add-in Extensible Project as shown in the screen below.



      II. Refer to the below screenshots for rest of the settings: 



The name must start with a letter and can contain only alphanumeric characters and underscores.

Note: After the support has been developed and deployed to the QTP, the QTP displays the custom toolkit name in all of the dialog boxes that display lists of add-ins or supported environments




     III. Create Custom Support Class: A package with the name “com.mercury.ftjadin.qtsupport.<Custom Toolkit Name>.cs”  will already be existing. Into this subpackage create a custom class. The steps for the same are as follows:




Select the option “QuickTest Custom Support Class” as shown below






In the Custom toolkit tree pane, the structure of the project is displayed, which can be selected for the custom toolkit class. Click Next Button



A. Selecting “Same as base support class”, will map the test object to the class whose support needs to be extended provided  test object is also a logical test object for the custom class
B. “Existing test object class” option needs to be selected when test object class does not adequately represents the custom controls
C. “New test object class” option is selected when a new test object class needs to be created which will support custom controls by extending existing test object.

On Clicking next, following screen will be displayed. Over here Identification properties (to override) can be selected. Also the additional/new identification properties can be defined.




On Clicking next, following screen will be displayed. Over here test object methods (to override) can be selected. Also the additional/new test object methods can be defined.



Click Finish.

Hierarchy of QTP Extensible project in Eclipse

Refer to the below screenshot



The project has following components:

I. JRE system library: These are the API’s which are included by default into the project at the time of its creation. 

II. Src: Into the Src folder, there is a custom support class for each supported custom class. The custom support class provides the actual interface between the custom class methods and the QuickTest capabilities, thus providing the QuickTest Java Add-in Extensibility.

III. Referenced Library: This folder contains the API’s/external Jars.

IV. Configuration: This folder contains the 2 XML files. 

File <custom_toolkit_name>TestObjects.xml- is a test object configuration file. It contains the description of the test objects created during the project.

File <Custom Toolkit Name>.xml-
This file provides the information that QuickTest needs to find the classes of the custom toolkit support set. The toolkit configuration file specifies:

* The location of the toolkit support class
* The location of the compiled support classes (a class folder or Java archive)
* QuickTest adds this location to the Java application Class Path when the application runs, enabling the application to find the required support classes.
* The support toolkit description: QuickTest displays the description in the Add-in Manager when a user selects the custom toolkit’s name in the list of available add-ins. 
* A mapping of each custom class to its custom support class. A single custom support class can be mapped to more than one custom class, but each custom class can be mapped to only one custom support class.


Deploying the Extensibility toolkit

The following table describes the appropriate location for each of the toolkit support files:


File Name

Location
<Custom Toolkit Name>.xml
<QuickTest Installation Folder>\bin\java\classes\extension

<Custom Toolkit Name>TestObjects.xml
Optional. Required only if mapping custom classes to new test object classes.
Note: This file name convention is used by the Java Add-in Extensibility wizard. You can have more than one test object configuration file, and name them as you wish.

➤ <QuickTest Installation Folder>\Dat\Extensibility\Java
➤ <QuickTest Add-in for Quality Center Installation Folder>\Dat\Extensibility\Java
(Optional. Required only if QuickTest Add-in for Quality Center is installed)

<Custom Toolkit Name>Support.class
All of the Java support classes can be packaged in class folders or Java archives on the computer on which
QuickTest is installed, or in an accessible network location.
Specify the location in <Custom Toolkit Name>.xml

<CustomClass>CS.class

Icon files for new test object classes (optional)

The file can be a .dll or .ico file, locatedon the computer on which QuickTest is installed, or in an accessible network location.
Specify the location in <Custom Toolkit Name>TestObjects.xml



Deploying Custom Support During the Development Stage

During the design stages of the custom toolkit support, the support class files can remain in your workspace. The custom toolkit support can be deployed by placing the toolkit configuration files (including the test object configuration file) in the correct locations, and by specifying the location of the compiled support classes in the toolkit configuration (XML) file. In addition, if the new test object classes use specific icons, their locations in the test object configuration file needs to be specified.

If custom toolkit support is developed using the QuickTest Java Add-in Extensibility plug-in in Eclipse, and QuickTest is installed on your computer, then toolkit support can be deployed by clicking the Deploy Toolkit Support Eclipse toolbar button, or by choosing QuickTest > Deploy Toolkit Support. The XML configuration files are copied to the correct QuickTest locations, while the Java class files remain in the Eclipse workspace. (The actual locations of the toolkit support class and the custom support classes are listed in the toolkit configuration file.)

If the QuickTest Java Add-in Extensibility plug-in in Eclipse is not used, or if QuickTest is installed on another computer, the deployment must be performed manually, according to the information in Above table

To deploy custom support manually during the development stages:
1. 1 Make sure that the compiled support classes (toolkit support class and custom support classes) are in a location that can be accessed by QuickTest.
2. 2 Update the configuration files with the correct locations of the compiled support classes and icon files (if relevant).
3. 3 Copy the configuration files to the appropriate folders, as described in above table.


Deploying Custom Support After the Design is Completed

When the custom toolkit support is fully designed, it can be deployed to any computer on which QuickTest is installed.

To deploy custom support after the design is completed:
1. Place the compiled support classes (toolkit support class and custom support classes) in their permanent location. The classes can be in class folders or in a Java archive, in a location that can be accessed by QuickTest. In addition, if new test object classes  are present using specific icons, place the icon files in a location that can be accessed by QuickTest. 
2. Update the toolkit configuration file with the correct location of the compiled support classes. If necessary, update the test object configuration file with the correct location of the icon files.
3. Copy the configuration files to the appropriate folders, as described in above table.

2 comments:

  1. Superb!!!! Can u show it the same for the WPF controls for dot NET suing VS 2010 IDE

    ReplyDelete
  2. What to do when QTP does not recognize an object? I've checked the loaded add-ins. How can this issue can be resolved? Please help if you've some knowledge about it.

    My Signature: Best dental websites design to attract new clients.

    ReplyDelete