“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.
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.
Note: – The CreateItem API can either be called by testcase script or by individual components.
3. Data Driven Testing Framework: –
Choosing a Global Software Development Partner to Accelerate Your Digital Strategy
To be successful and outpace the competition, you need a software development partner that excels in exactly the type of digital projects you are now faced with accelerating, and in the most cost effective and optimized way possible.
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.
The external file what we choose is ‘Register.xls’ as shown below:-
I have prepared data for 5 iterations. So my pseudo code would be:-
/* 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.
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: –
// 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:-