Introducing frameworks

A framework is defined as a broad overview, guideline, or skeleton of the interlinked components, which supports a particular approach to a specific objective, and serves as a guide that can be enhanced as required by adding or deleting components. A framework is a working or conceptual model that supports or provides guidelines for creating or expanding the test scripts to achieve the test automation, ensuring lower maintenance and easy expandability.

A test automation framework is a layered structure and provides the mechanism to interrelate and interact with each other to achieve the common goals. Frameworks also include actual programs and interfaces or offer utility tools for using the frameworks. A framework facilitates a standard way for modifying, adding, and deleting the scripts and functions. It's a comprehensive structure that provides scalability and reliability with less efforts.

Automation goals can be achieved by selecting the right framework that is suitable for test automation. The cost of test automation includes both development and maintenance efforts. Selecting the suitable framework and techniques helps in maintaining the lower cost and high impact solution.

The automation framework and types of framework

In general, various structures and techniques are used to design the framework. Broadly based on these techniques and structures, we can classify the framework as follows:

  • Linear: In this the script is created in a linear fashion, usually generated by recording and replaying without or with only slight modification.
  • Data-driven: Parameterizes the test and fetches data from a persistent data source. The data source could be internal or external to the test.
  • Modular: A modular framework is designed to achieve modularity at test as well as script levels. The modular framework can be of the following combinations:
    • Test script modular framework
    • Test library modular framework
  • Keyword-driven: Keyword-driven framework is designed for reducing the maintenance cost by separating test cases from their execution.
  • Hybrid: In this, two or more of the previous patterns are used.

Record and replay

Recording is the process of capturing an object and its properties, creating the test objects, and storing them in the Object Repository with hierarchy. Assign a logical name to the test object and create the scripts by capturing the operation performed on the GUI.

Record and replay

The preceding screenshot shows the AUT, recorded script, and OR. The AUT contains the test objects. OR stores the test objects in an hierarchy and with their identification properties:

The recorded scripts take us through the following three test steps:

  1. Click on the Login dialog.
  2. Enter ashish in the Agent Name textbox.
  3. Enter the password.

A test step contains test objects with hierarchy, operation, and data value (if applicable) for the test object. While recording the user action on AUT, OR creation and scripts generation almost happen simultaneously. This approach is also called the QTP linear framework approach. In the linear framework approach, scripts are recorded in a step-by-step fashion without focusing on reusability. Consider an example where you have a test case to log in to an application, search for some data and then log out. In the linear framework, the code would look like something shown in the following example:

Steps for creating the QTP linear framework:

  1. Enter username.
  2. Enter password.
  3. Click on the OK button.
  4. Enter the Flight date.
  5. Select Fly From (source).
  6. Select Fly To (destination).
  7. Click on the FLIGHT button.
  8. Click on the OK button.
  9. Enter the name.
  10. Click on the Insert Order button.
  11. Close the Flight Reservation window.
'Login 
Dialog("DialogLogin").Activate
Dialog("DialogLogin").WinEdit("EditAgentName:").Set "ashish"    'Enter the agent name
Dialog("DialogLogin").WinEdit("EditPassword:").SetSecure "51e6911da82a99155f73b209eaeac51a66ef0883" ' Enter password
'Create Order
Window("WinFlight").Activate
Window("WinFlight").ActiveX("MaskEdBox").Type "111114"             'Enter Flight Date 
Window("WinFlight").WinComboBox("FlyFrom").Select "London"  ' Select Source 
Window("WinFlight").WinComboBox("Fly To:").Select "Frankfurt"     'Select destination
Window("WinFlight").WinButton("btnFLIGHT").Click                                        'Click on flight button
Window("WinFlight").Dialog("FlightTable").WinButton("btnOK").Click 'Click on the OK button
Window("WinFlight").WinEdit("EditName:").Set "Mr. James Anderson" 'Enter the passenger name
Window("WinFlight").WinButton("btnInsertOrder").Click'Click on the Insert Order button
Window("WinFlight").Activate
Window("WinFlight").Close'Click on the close button

This is the simplest way to create scripts and use and implement them if the AUT is small, but do not expect frequent changes in AUT. The normal record and playback falls under this framework.

Advantages and disadvantages of linear a framework

The advantages of linear framework are stated as follows:

  • No expertize or experience of programming or designing is required. Basic knowledge of QTP is required for creating scripts.
  • Automatic test object creation and storage in the Object Repository.
  • This is the fastest way to create test automation scripts.
  • This is the simplest framework, and it is easy to understand.
  • Helps to learn the objects and create the scripts manually.
  • Can add checkpoints easily.

The disadvantages of linear framework are stated as follows:

  • Does not allow reusability since scripts are created in a linear fashion and do not have functions.
  • Data is bound with the scripts; hence, the test is noniterative, and this approach is inefficient for executing the test for multiple sets of data. Change the data manually for each run or create multiple copies of scripts; unfortunately, both of these techniques are inefficient.
  • The maintenance cost is very high, and it is tedious, and error-prone since it is required to make changes in all the affected areas.
  • Need to add comments on our own.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.76.89