Essentials of Typical QTP/UFT Framework

The main components of a typical automation framework

Table of Contents

As we discussed the types of QTP/UFT frameworks earlier in our post ‘Traditional Framework Definitions‘. In continuation of that, this article talks about the ‘essential components of a typical framework.

Irrespective of the kind of framework you choose, whether it’s Data-Driven, Keyword Driven, or BPT Framework, etc., one must address the following components which are hereby cited hereby as ‘essentials’. These components shall serve as the fundamental building blocks of your framework.

Personally, my choice is always the so-called ‘Hybrid framework’. In such a framework at a lower level, you can create data in external files as in a data-driven approach, and creation of keywords as in keyword driven framework, while keeping Functional decomposition as an ‘Umbrella’ strategy. Now tailor it all together alongside your project requirements and you get a potential ‘Hybrid Framework’. It just gives you all the benefits in one!

Essentials 1: Test Artefacts Repository 

By test artefacts, we mean scripts, function library, object repository etc. and even including the test cycle results. Of course, using a shared central repository with reasonable versioning makes sense and hence the most obvious choice should be HP Quality Center and if it’s added with a bit of ALM related salt then nothing like it!

Following are some of the upfront benefits of choosing HPQC ALM as your test artefact repository :

  • Option to run test sets / suite.
  • Option to view results.
  • Options to plan test cycles
  • Shared access for multiple users.
  • Versioning of test scripts, function libraries, object repository and test data

Essentials 2: Error Handling and Recovery

There is no doubt that without proper error handling or lack of recovery scenario would land you frequently into debugging your test scripts, test environment or data. You may end up re-running your test cycle or tests multiple times due to interruption caused as a result of such script failures.

In many cases, a lack of error handling may also give false or invalid results as the script may just go over without capturing errors or failures and still marking the scripts as ‘passed’

Hence your script or code should be built with sufficient error handling and recovery scenarios. Error Handling can be implemented using QTP/UFT inbuilt ‘recovery scenario manager‘ or manually through custom scripting in your script of library code.:

  • Error handling via custom code:
    1. Option Explicit: Using ‘Option explicit’ forces, explicit declaration of all the variables used in the code. If you use this statement at the beginning of the program then you are bound to declare each variable explicitly using Dim else the script engine shall produce an error. This ensures you are not duplicating variables or losing variables thereby more stricter use and re-use of variables throughout the program.
    2. Err Object: The ‘err’ is a VBScript language object which stores information about the last error that occurred during script execution. This object has further in-built functions for more verbose discovery of the error. For example, err.description, and err.number tells about the description and number of err.number has value 0 in case no error occurs in script execution err object together with conditional loop can help in the handling of error.
    3. On error Statement: Using an ‘On Error Statement’ you basically inform the VBScript engine that you want to handle errors manually instead of allowing the VBScript engine to display a typically ib-built error message and halt the program.
    4. Exit statement: This provides for a graceful and informed exit from a procedure. You may use this to exit from loop/actions/tests and function based on implementation of exit statements like exit for/exit function/exit action/exit test statements
  • Test Settings in QTP: This is a global or umbrella setting which you can enforce at QTP level. Using this option, we can instruct QTP to perform required action in case error is encountered in script execution. For e.g. proceed to next step/stop execution or a pop up message box.
  • Recovery Scenario: The recovery scenario is another great way in-built into QTP / UFT for graceful handling of errors. Using the Recovery Scenario Manager wizard you can define your own recovery scenario by choosing in-built options from the wizard. This basically includes a definition of an unexpected event and the operations necessary to recover the run session.

Essentials 3: Object Identification Method

This is again one of the most important aspects of any automation framework. This basically means, ‘how your automation tool recognizes or identifies the AUT UI, UI elements/components’ etc.

With QTP/UFT you have the following choices for object identification. Which method you choose does steer your script development and usability aspect of the framework :

  1. Using Object Repository – Object in application are stored in object repositories. Useful for static objects.
  2. Using Descriptive Programming – Object properties and value can be stored in an external vbs file and can be called in the script. Can be called from functions using descriptive programming for object identification.
  3. Using HTML DOM – HTML DOM structure can be useful to identify objects in case object is not identified using DP or Object repository methods.
  4. Using XPath/CSS – XPATH/CSS can be useful to identify objects in case object is not identified using DP or Object repository methods.

Note: The recommended object identification should always be Object Repository. You should use HTML DOM/CSS//XPath only if an object cannot be identified using object repository or Descriptive Programming. It might look less tech savvy but in the long run, it may prove good at usability and maintainability purposes

Essentials 4: Test Data Management

Test Data provisions and strategy is another important aspect that should be a part of a good framework. With data parameterization, your test data would be kept separate from the code. And this will ensure that the same code can be re-used for different sets of data.

There can be a variety of Test Data sources options such as excel files, database, text files and XML files. But generally, the best one is mostly Excel or CSV:

You should adhere to following considerations and best practices for test data :

  • Test data should be maintained in the external data source that can be an Excel, database or CSV.
  • think of employing test generator tools that can create random data to test an application.
  • Random Test Data needs and hence random generator modules
  • Types of validations required, single line, character, string, bulk data validations (compare two excel or pdf outputs) etc.

Elapsed time in loading test data: ‘Should you load all data globally before triggering any test suite?’ or ‘Should you load test data per-test basis?’ Hence this generally calls for carefully choosing the data source and weighing against the loading strategy. As a case study, in one of the projects, I observed a lot of time spent in loading data for each test individual basis from a database source. Not a good idea due to time spent in connecting/disconnecting from the database over a network!

Essentials 5: Result and Error Reporting

Ideally, a separate Reporting component can be developed which is basically a collection of Library functions and procedures customized for reporting only. Depending upon the project requirements and effort available, this reporting component may generally make use of external databases (MSAccess), excel files or text log files to write the output of the tests. such a provision comes handy when you want to drill down to errors or failures by applying filters on databases or file output.

Avoid implementing reporting into individual scripts directly using reporter.reportevent, WScript.Echo, MsgBox or any such statement, instead you should at least develop a small separate module for such functionality into your function library

On a last note, an HTML based result report generally offers the best presentation and usability. A good framework would generally have such customized HTML based result reporting module.

Essentials 6: Function Libraries Repository

Supporting Libraries is again one of the most fundamental and required part of any good framework.

Below is one such best practices for libraries and scope of libraries that can be maintained:

  • Driver Script (Orchestrator): A driver script or as I call it, an ‘orchestrator script’ can be created to control the flow of test script execution. It mainly drives the order of test script or test set execution, calling and loading dependencies, triggering pre-test environment checks etc.
  • Initialization Library: Initialization library initialize test execution and loads object repository, environment variables, business and support function libraries, closing open instances of the application and so on. This contains all function for initialization of test execution.
  • Common Function libraries: This library should include functions for reporting, error handling, and all support functions like Date/time functions, string manipulation and external file manipulation that are used as support functions by business functions.
  • Business Function Libraries: Business Function Libraries includes application-specific functions and works with manipulating objects in the applications. These functions cover the business flows.
Tushar Sharma
Tushar Sharmahttps://www.automationdojos.com
Hi! This is Tushar, the author of 'Automation Dojos'. A passionate IT professional with a big appetite for learning, I enjoy technical content creation and curation. Hope you are having a good time! Don't forget to subscribe and stay in touch. Wishing you happy learning!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

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

Recent Posts

RELATED POSTS

Best Practices For Evaluating Automation Tool

With rapidly changing financial conditions, businesses face the tough challenge of optimizing resources to produce maximum results. Choosing the right automation tool for functional...

Getting Started with Selenium WebDriver

Table of Contents 1. Selenium and Selenium Web Driver 2. Setting-Up the Environment 3. Test Script with Selenium Web Driver 3.1) Creating a project 3.2) Creating...

A Brief Review Of WATIR

WATIR stands for 'Web Testing Application in Ruby'. It is an OLE-based testing application that automates your browser using Ruby libraries. Here are some...

Â

RECENT 'HOW-TO'

How To Install Oh-My-Posh On Windows PowerShell

Oh-My-Posh is a powerful custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable. It does not...

SIMILAR ON CODEX

FEATURED PROJECTS

Windows JDK Manager (win-jdk-Manager)

ADjo LABS PROJECT : Simple and lightweight desktop utility with Interactive cmd Interface for easy view, re-point and switching between JAVA versions on windows. Demonstrating the capability...

MORE IN THIS CATEGORY

Introducing Testing-as-a-Service (TaaS)

The 'Cloud Computing' technology has revolutionized the IT industry and it has something good to offer to the testing industry too. After Iaas, PaaS,...

Common Errors with QTP/UFT – Part 1

As the name suggests, this article focuses on the common problems faced during or after QTP/UFT installation. We shall also have a separate article...

Working with Selenium WebElements

Table of Contents 1. Selenium WebElements 2. WebElement Locators 3. Working With Text Box 4. Working With Buttons 5. Checkboxes and Radio Buttons 6....

CHECKOUT TUTORIALS

VBS Part 1 – Introduction and Background

At the upfront, this theoretical article might look boring to most of us but still, it is advisable to know about our scripting friend...
- Advertisement -spot_img