Skip to main content

Development

Types of Automation Framework

“A Test Automation framework is a set of assumptions, concepts and tools that provide support for automated software testing”.

So why do we need Automation framework. Can’t we just record the steps of any test case using the automation tool and playback whenever we want to execute the testcase? The answer is ‘NO’.

Let’s see the Record/Playback Myth.

–  Taking manual testcases into account, we need to perform the same action using any automation tool on the application under test.

–  Using the capture feature of the tool, we can record the action.

–  Playback the recorded script and verify the results in the log.

Since we have recorded the script, the input values would have been hard-coded which needs to be changed if something changes in the application under test.

Now say suppose you have a registration page (say in Gmail) if you record the script by giving user name as ‘xxx’ and submit the page.  If you try to playback the same recorded script, it will fail giving the error ‘username xxx already exists’. Also there could be multiple unwanted popups shown up which will make our test execution fail.

Hence record and playback doesn’t provide robustness and reliability to our automation script.

In order to avoid such kind of problems, implementation of proper framework is a must that suits our requirement. Let’s see the different types of frameworks:-
1. Modular Framework: –

This is the most common framework which we will come across. Here we create independent scripts also called components that usually represent modules or functions of application under test. Also we can create a testcase script which can be used to invoke one or more components. As a whole these individual components can be combined or taken together to form a larger test in a hierarchical manner. Using this modular framework, overall maintainability of scripts becomes easier.

Modular Framework

Modular Framework

Note: – testcase script can invoke all the 3 components as shown above depending upon the business logic.

 

2. Library Architecture Framework: – 

Library Architecture framework is very similar to Modular framework. The difference lies here; the application under test is divided into procedures and functions instead of scripts. This mainly involves formulating reusable functions into library files (such as DLLs, APIs, library functions) and these library files can be called directly from any component.

CreateItem API is a library file created in order to reduce the time taken for execution of CreateItem script again and again.

For example: – To execute ModifyItem / DeleteItem script, we need to have an Item created in database as part of prerequisite. In order to achieve this we need to execute CreateItem script every time before executing Modify / Delete script.

So an alternative would be to create a library file (CreateItem API) and execute it (which will insert newly created item in DB), this will reduce the time taken by CreateItem script and once the record in inserted into the DB , we can execute Modify / Delete script.

Library Architecture

Library Architecture

Note: – The CreateItem API can either be called by testcase script or by individual components.

 

3.  Data Driven Testing Framework: –

Data Driven testing approach is mainly used to overcome the problems of hard-coded input values as mentioned above for Gmail registration page. The framework can accept input values from an external file (such as CSV files, Excel files, ODBC sources, ADO objects etc.) and store in a variable and once execution is completed, can also store the output in another variable pertaining to the input. For example, In Gmail registration I can ask my script to take new set of data (present in external file) every time when I execute the script.

Gmail Registration Page

Gmail Registration Page

The external file what we choose is ‘Register.xls’ as shown below:-

Register.xls

Register.xls

I have prepared data for 5 iterations. So my pseudo code would be:-

Function Name()

{
/* Parameterization */

//code to input First1 as FirstName

//code to input Last1 as LastName

//code to input First1 as ChooseYourUserName

//code to input pass1 as Password

//code to input pass1 as ConfirmPassword

}

//Looping 5 times

// the above code continues for 5 iterations creating 5 sets of data (i.e. 5 different usernames).

 

4. Keyword Driven Testing Framework: –

Keyword Driven testing approach mainly deals with 3 components which we define in the form of datatable.

Keyword: Keywords that defines certain actions in GUI. For example: – TypeText, Set, Click etc., which has a meaningful action name.

Application Map: These are named references that specify elements in an application. i.e. Object Repository (Identifiers of elements).

Component Function: These are functions which manipulate the GUI elements. For example: – Click on a button, enter name in the text box etc.

In this approach, the dataset is documented in a tabular form and provides step by step instructions for each test.

Object(Application Map) Keyword Arguments
Textbox(username) Set Amit
Textbox(password) Set Xxxxx
Button(Login) Click

 

Once the data table is ready, we can write program/set of scripts that reads each step in the data table and execute the step based on the keyword contained the Action field as shown below: –

Function Name()

{

// code to connect to the data table

//code to parse the Keyword (Action) one by one

//code to do the task based on the Keyword

// Abort the connection

}

 

5. Hybrid Automation Framework: –

The Hybrid Automation framework is nothing but combination of above frameworks by considering the advantages of different frameworks. This may consist of a driver script that drives multiple data driven scripts that take advantages of Library files (that in turn connects to DB) and follow the keyword approach by creating a datatable containing all keywords along with actions. Sample Hybrid framework screenshot is shown below:-

Hybrid Framework

Hybrid Framework

Thoughts on “Types of Automation Framework”

  1. Sohit Kanwar Post author

    Hi Shashidhar,

    Let me put this in form of the example which i have mentioned above. Suppose you have an application consists of 3 major modules as follows:-

    – CreateItem
    – ModifyItem
    – DeleteItem

    Now considering the modular framework, i will create 3 scripts pertaining to 3 modules of the application (Note that you can create n no. of modules depending on your requirement) along with the driver script(i.e. testcase script).

    – CreateItem script(will be having steps to create an item)
    – ModifyItem script(will be having steps to modify an item)
    – DeleteItem script(will be having steps to delete an item)
    – testcase script (driver script, can be used to call scripts)

    Now let’s see the execution part, say my requirement is to execute DeleteItem task. So i will configure my testcase script as follows:-

    – CreateItem script
    – DeleteItem script

    So this means smaller tests tend to form a larger tests in a hierarchical manner.

    Now if we look at the advantages of it, maintainability of the scripts becomes easy i.e. in future if something changes in DeleteItem page. We just need to modify DeleteItem script without touching any other existing script.

    Let me know if this looks clear.

  2. Sohit,can you please confirm that can’t we run independent script(Component) with out the help of test case Script in Modular framework?

  3. Sohit Kanwar Post author

    Abhilash,

    Yes we can run individual scripts without using testcase script. It’s just that involving testcase script provides another abstraction layer from which user is not exposed to actual logic.

  4. Thanks for the explanation Sohit that was really wonderful.Can you please explain which Frame work is better ? and how to identify ?

  5. Sohit Kanwar Post author

    Shashidhar,

    it’s hard to answer that question. Every framework has it’s own advantages and disadvantages.
    But yes the foremost thing should be to make your test scripts modular as stated by Modular framework that will help you to maintain the scripts with ease.

    Rest all depends on the project and the priorities.

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.

Sohit Kanwar

More from this Author

Categories
Follow Us