What are Frameworks?
Frameworks can be defined as a set of well integrated structure of codes, tools, or processes which bring together the clarity and ideas of a job. With respect to development, a framework can simplify the code maintenance and improves readability. Therefore, when it comes to test automation, a framework helps in figuring out which programming language to choose so as to execute the tests, as they are able to model the state of application of the tests that are being executed and also increases the test speed and efficiency.
Why do we need a Test Automation Framework?
Frameworks are employed, primarily for their ability to improve different aspects of the automation test scripts, which are to be executed. These include readability, re-usability, portability, understandability, cost effectiveness, etc. Thus, to make improvements to one or more of these aspects, it is recommended to employ at least one framework in the automation testing process. Moreover, situations can arise where different people working on different modules of the same application implement different approaches towards automation. Such situations can be avoided, by implementing a single standard test automation framework.
Types of Frameworks
There are a wide range of test automation frameworks available nowadays:
- Keyword Driven Framework.
- Data Driven Framework.
- Page Object Framework.
- Hybrid Framework.
- Keyword Driven Framework
Also known as Table-Driven Framework, Keyword Driven Framework mainly consists of 3 components: Keyword, Application Map, and Component Function. It requires the use of data tables and keywords, specified in excel sheet. These data are independent of the testing tool, that is being used to run the automation test scripts. That is, keywords are stored in an external data table. A Keyword, by definition, with respect to Keyword Driven Framework is simply an action that can be performed on an interface component, i.e., an input text, a verify value, and so on. These keywords can be used across multiple test scripts, making the code reusable. These entities are stored in a step-by-step manner, with its related object or with a part of the UI. They can be labeled as simple keywords like ‘click’, ‘login’, etc. or complex words ‘clicklink’, ‘openlink’, ‘submitform’, etc.
There are 3 essential components related to Keyword Driven Framework: Keyword, Application Map and Component Function. A Keyword, as defined earlier, is an action that can be performed on an interface component, which is an input text. An application map, however, provides references that are labeled. They are created for GUI components. In Short, Application Maps are simply nothing but “Object Repository”. The third entity is the Component Function. Component Functions are methods that interacts or actively manipulate the GUI component. The method can be application dependent or independent.
Even though minimal scripting knowledge is required for automating the test cases, setting up the framework is a complex and a time consuming process, thus requiring expertise. Also maintaining the keywords, while scaling up a process, is a hassle.
- Data Driven Framework
In this type of framework, the data which is used for running the tests can be stored externally. This is mainly due to the fact that the main purpose of Data Driven Framework is to separate the test script logic from the test data. Different sets of test data can be passed by the creation of different automation tests. These test data can be stored externally as Excel Sheets, Access Tables, XML files, etc. These resources can be connected with the test scripts to collect the test data, using variables. Variables can be used as a verification value and also as input values.
The main takeaway from this framework is that the test coverage is more, and there is scope for reusing tests. It is also to be noted that tests can be executed only when required, making it more flexible. Hard coding the data is no longer necessary, hence the test script can be modified without affecting the test data and vice versa. However, the main drawback is its time consumption for the initial setup, similar to the Keyword Driven Framework.
- Page Object Model Framework
The page object model or POM is actually a sort of design pattern that is commonly used these days. If a web application is considered as a network of pages, where a large number of page features change, then this framework is much more suitable to implement.
The POM involves the creation of an Object repository, known as Page Object, which is an object oriented class. It acts as an interface for the Application page that is under test. A corresponding Page Class exists, for each web page in the application. Each of the page classes contain the web elements and methods of the corresponding webpage of the application. It is to be noted that, the method(s) involved in each page class interact with the assigned web elements of that particular page class. While automating the test cases, an object for each page class is created, and the method(s) is/are called, to interact with the web elements.
Though page objects can be created for each page, there will be instances, that depends on how the web page is modelled into a page object. Asynchronous web components, like ajax calls, must be handled separately, even though the network of page objects ultimately models the state of web applications. Anyway, the main advantage of the page object model is the ability to define navigation logic between pages so as to tie the link between different pages, in a web application. Another benefit is that, whenever an html locator information changes, and a change is made in the page object, it is reflected across all the scripts. The page class can also be reused, if needed to be used in another test case, and the user need not rewrite the code for identifying the web elements and methods to interact with them for every test case.
- Hybrid Framework
Leveraging the benefits and strengths of two or more frameworks, depending on the test environment, is the main objective of using a Hybrid Framework. That is, it tries to mitigate the weaknesses of the frameworks, involved. Hybrid frameworks are what most frameworks evolve into over time, or must evolve into. The user must have thorough expertise in all of the frameworks, involved, in order to set up the framework.
The frameworks for test automation, mentioned above, are only some of the commonly used types by various teams for various projects. In case of Hybrid Framework, it is advisable to implement a tool that can quickly and easily adapt with the proposed idea of a Hybrid Framework. While choosing an automated testing tool, it is recommended to use one that is more flexible and that can support a wide range of applications and languages. This would help your team, to contribute more into your testing efforts, regardless of their skill set.