Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts

How to create a Hybrid Framework in QTP

A hybrid Framework is a framework that uses features of multiple frameworks and is more robust. For e.g, we can create data in external files as in data-driven approach, or creation of keywords as in keyword driven framework. 


Before understanding what needs to be a part of hybrid framework, it is necessary to know what are essential requirements of a framework, Below are the points that needs to be considered before creating a framework.

1. Identify where Test Artifacts needs to be maintained 


Test Artifacts can be maintained in test management tools like Quality Center or can be stored in a shared repository. Using a test management tool, For e.g HP ALM provides following features 

  •  Version controlling of test scripts, function libraries, Object repository, recovery scenario and test data
  •  Multiple Users can at the same time can access the resources in tool.
  • Option to run  set of tests and defining the execution flow can be done using test management tool.


In case of test management tool not available, Test Artifacts should be maintained in a shared folder, so that multiple user can have access to the  resources. In this case, we will require a driver script that will execute multiple test script in a batch and also can be scheduled.

2. Object Identification


Objects Identification is very important and can be identified in number of ways. Some of them are as follows

  • Using Object Repository
  • Using Descriptive Programming
  • Using HTML dom.
  • Using XPath/CSS

A hybrid approach can use a mix of various object identification techniques and can maintain object of different types in different vbs files which can be executed during test initialization.

3. Error Handling and Recovery Scenario


For expected errors, error handling should be implemented in the code and recovery scenario can be used to avoid interruption in test script execution.Code should have enough error handling defined.

4. Reporting


For each failed/passed step in test script execution, reporting in QTP results or user defined html results should be done. Reporting should not be direct using reporter.reportevent but should be wrapped in a function with arguments defined for taking screenshot or exiting the test based on flag status of the argument.

5. Test Data Management


Test data is an important factor in hybrid framework design. Preparation of test data should take into considerations factors like:

  • What are the validations required for test data preparation in fields
  • Can any random data be entered in the fields.
  • How much data is required. e.g bulk data required to execute scripts for multiple iterations.
  • What will be the source of data. Data can be stored on an excel file or can be imported from database at run time if specific existing data is required.
  • In case of large data requirement, test data generation tools like GenerateData can be used.

6. Libraries Management


For each test script execution, An initialization library should be called at the start of script execution which should load the required environment variables, object repositories and other function libraries with application specific code.
Similarly before exit from test script execution, function to close all process that were called during script execution should be executed. Also Code should have enough error handling and reporting, minimum hard code data, and should follow standing coding practices

How to capture images and create movie to be saved with QTP

QTP provides options to captures images and record movies of test script execution. User can define the setting for image Capture and screen recorder before test script execution. 

To define settings for images capture and screen recorder, Navigate to Tools>Options>Run>Screen Capture.

Click on Checkbox to save still image captures to results or click on checkbox for save movies to results.


Select whether to save images/capture movies always or only for error as shown below.



Settings for Screen capture in QTP
Settings for Screen capture in QTP

Once test is executed, recorded movie can be viewed in results as shown below



Viewing recorded movie in results
Viewing recorded movie in results

Understanding Object Repositories Manager: Managing Objects

1.  How to Import Object Repository from xml file


Object repository can be loaded from an external xml file using object repository manager.


Importing and exporting Object Repositories to/from xml file


2.  How to export Object Repository to a xml file


Object repository can be exported to an external file using object repository manager.


3. Defining Objects manually in object repository 


      A new test object can be added manually using object repository manager. Below are the steps to add object manually in the object repository

Adding Object manually in Object repository

  • Navigate to Resources>Object Repository Manager
  • Navigate to Object>Define New Test Objects
  • Define new test Object with environment, name, and class of object and add description properties to object.
  • Click on Add to add object.
  • Save object repository as shared object repository


4.       Add Object to repository

  • User can add an object from  application without recording
  • Navigate to Resources>Object Repository Manager.
  • Navigate to Object>Add Objects
  • Focus on object to be added and click.
  • Object is added to repository.


5.       Navigate and Learn

  • User can add required objects from application using Navigate and Learn.
  • Navigate to Resources>Object Repository Manager.
  • Navigate to Object>Navigate and Learn or press F6.
  • Define the filter for objects to be added.
  • Click on learn button.
  • Object will be added to object repository


·          
Options of Working with object

6.       Update Object from Application

  • User can update objects from application with below steps
  • Navigate to Resources>Object Repository Manager.
  • Select an object to be updated. Please note updated object class should be same as the class of object by which it is to be updated.
  • Navigate to Object>Update from application
  • Object properties are updated