QTP/UFT – Hybrid Test Automation Framework

There are 4 most popularly used automation frameworks.

  1. Modular
  2. Data driven
  3. Keyword Driven
  4. Hybrid

First 3 frameworks have their own pros and cons. Hybrid framework is the combination of all 3 by using all the pros and minimizing the cons.

In this post, I would like to show how I have implemented my hybrid automation framework using QTP for one of the projects.

Folder Structure:

My folder structure is as given below.

hy001

  • data – contains all the test data/expected files to be compared/files to be uploaded for testing purposes.
  • lib – contains reusable application independent jar/dll
  • objectrepository – properties to identify the elements in the application. [I have used a lot of descriptive programming. But I also like to keep the test identification properties away from the test script.]
  • functions – VBScript / Javascript functions/Business actions.
  • properties – test environment/database details / any test execution specific details.
  • tests – Spreadsheet containing all the automated test cases details & keywords to be called.
  • suites – test suites which contains test case numbers to be executed.
  • output – it has sub folders for storing the result files, log files, any files to be downloaded while the test is running.
  • runner.exe – an executable – driver script which launches QTP & executes the test

Lib Folder:

If I need to create some libraries which is not going to be application dependent, then i write that in .net instead of VBScript. Because We can write better code in .Net, it runs faster, has many reusable libraries, OOPs support, better error handling than VBScript.

Ex: I have below utilities created.

  • ExcelUtil – To read spreasheet, compare etc
  • JSONUtil – to read/write files
  • ReportUtil – To create custom execution report once the test execution is complete.
  • DBUtil – To connect to the DB & execute queries
  • SMTPUtil – To send emails
  • IMAPUtil – To read emails & extract the content
  • ImageUtil – To create/compare images
  • ChartUtil – To create charts for the given data
  • PDFUtil – To read/write/compare PDF files

Properties Folder:

This folder contains a default properties file & an environment specific property file.

hy008

 

Each property is set as Environment Variable for QTP.

Functions Folder:

These are all application specific business actions written in VBScript.

Ex: I have below action keywords to execute some business functionalities specific to my application under test.

  • CREATE_ORDER – to create an order for an user
  • VIEW_ORDER – to view an existing order
  • EDIT_ORDER – to edit an existing order
  • DELETE_ORDER – to delete an existing order
  • CREATE_USER – to create user
  • SEARCH_USER – to search for an user

Above high level business action/keywords are QTP/Selenium automated test scripts. Whenever these keywords are called, the corresponding test script is executed.

For Ex: It could be something like this.

Function CREATE_ORDER

' select product for the given product code
' click on order button
' enter payment details
' checkout
' check for the conformation

End Function

Tests Folder:

It contains a spreadsheet in which we add the automated test cases.

TestCase sheet:

hy002

It contains list of all the testcases for the application. It contains the test case ID, test description & corresponding business actions to be executed. By calling these actions in the given sequence, we get the business flow verified.

For Ex: For TC001, We need to create an user & order a product. So we call 2 actions – CREATE_USER & CREATE_ORDER. To order different products, the same function is called as the business flow is same and only the product is different (Data-driven). So we create another test case, TC002 – We call those 2 actions again.
To get the testdata for the action, driver reads action-data mapping sheet.
For Ex: Below sheet shows that for CREATE_ORDER business action , it can find the test data in the ‘OrderInformation’ sheet.

hy003
Driver goes to ‘OrderInformation’ sheet and gets the test data from this sheet by using the testcase ID.  In the below image, TC001 & TC002 have different test data. Eventhough TC001 and TC002 have the actions, they use different test data and tests different products.

hy004

 

Suite Folder:

Test case spreadsheet contains all the possible test cases for the application. Suite file contains group of test cases to be executed for a functionality.

For ex: I might have 1000 automated test cases in total from different modules of the application. But i might be interested in running only 100 testcases specific to ‘order’ module as there could be a recent change in the particular module of the application. So i create a suite file which contains only order related cases to execute.

hy005

Sample Suite File:

hy006                               hy007

 

How It Works:

hy010

  • Runner.exe: It expects 3 parameters.
    • Environment in which all the tests need to be executed (like PRODUCTION/PPE/QA…)
    • Browser (IE/FF/Chrome)
    • Suite (name of the suite file which contains the test numbers to be executed.

It invokes the QTP using its Automation Object Model & loads the environment variables, starts running the QTP – It also keeps monitoring the execution, logs the results in the console.

Check here to log QTP result in the console.

  • Driver:
    • It reads test case IDs from the suite files.
    • Using these ID, It gets the Business Action Keywords to be executed from the ‘Tests’ spreadsheet.
    • For each Business Action Keyword, It reads the test data
    • Once the test data is read, It calls the Keyword.

Report:

The report utility creates a nice HTML as shown here. [I created the .net library to create the HTML report – but I used a CSS file to format the HTML from a blog long back. I forgot the site. Credit for the css should go there]

report

 

report2

Notification:

Once the execution is complete, It sends out a detailed information to the email addresses given in the property files. I use Jenkins plugin to send the emails. I also use another Jenkins plugin to send SMS notifications to your mobile device.

Summary

My aim was to give you a high level idea about the hybrid automation framework I have implemented. Please leave a comment in case of any questions / suggestions.

If you are interested in implementing something similar for your organization, Please refer to below posts of TestAutomationGuru.

 

 

Share This:

12 thoughts on “QTP/UFT – Hybrid Test Automation Framework

  1. I am new to QTP/UFT automation…..I was wondering is there anyway you can share/send the code. It would be highly appreciated. Thank you!

  2. The framework looks good and easy to understand ,beside i really like the Result as well as the reporting .I also want to implement this so could u please send me the code of the framework.

  3. thanks for the scripts .
    But in the scripts i am not able to find the Reports the one which which u have shown in the above post i.e hybrid test automation framework .so if you could please share me the code for this report .
    also could you please share ur mail id .

  4. Hello VIns, highly appreciate your blog and your passion for the work. Its greatly helpful . My question on the framework: Did you choose to do the framework due to absence of QC /ALM or chose to avoid the usage of QC- perhaps due to performance lags due to execution. In an Org where QC is used widely by customers , does it not provide better usability and ease of maintainance. We used BPT some time ago and modularized with functions. Your comments will be very valuable

    1. We still use ALM for writing manual test cases. I had also used BPT few years ago for sometime. Performance, Usability and maintenance are the main reasons for me to choose this framework instead of BPT in ALM. I also wanted to drive everything from Jenkins. Automated smoke test and regression tests using QTP are all part of the build pipelines and we do not trigger them manually! If BPT works for you, then it is great! There is no best framework / process. It will all change depends on the users, the organization process etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.