top of page
Search
Writer's pictureTuyen Nguyen

Keyword-Driven Testing Framework

Updated: Jul 29, 2024

As mentioned in Selenium Testing Framework before, and after the first framework (Data-Driven Testing Framework) in Selenium Testing Framework series, I will introduce one of the most powerful frameworks - Keyword-Driven Testing Framework.


What is Keyword-Driven Testing Framework?


A keyword-driven testing framework is a table-driven testing or action-based testing. This is a technique in which all the operations and instructions to be performed are written separately from the actual test cases.


For specification, it uses the data files to contain the keywords related to the application being tested. These keywords describe the set of actions that are required to perform a specific step.


A keyword-driven test consists of high and low-level keywords, including the keywords arguments, which are composed to describe the action of a test case.


In Keyword-Driven Testing, we may first identify a set of keywords and then associate an action (or a function) related to these keywords. For example, every action like open or close browser, click a button, type a text, scroll a screen, ... is described by a keyword such as openBrowser, closeBrowser, clickButton, type, scrollTo, ...


Why Keyword-Driven Testing?


We frequently have some actions that we want to execute multiple times in several different tests, but write the same definition for all the time we use it in many tests is an extremely monotonous and time-consuming task. This also causes the maintenance struggling, while there are changes in one function, we have to do the same massive effort on the other test functions to match with others.

Keyword-Driven Testing Framework

Example:

Testers want to test some complicated cases, in which they reuse some steps from other test cases.

  • Test case 1 has 3 steps: A, B, C

  • Test case 2 has 3 steps: C, D, A

  • Test case 3 has 3 steps: B, C

It will be time-consuming and hard to maintain when creating the same actions of steps again and again in each test script.

So it will be ideal to:

  • Define the actions of those steps inside one file (contains the implementations of A, B, C, D).

  • And from the test case, the test steps just specify the actions they want to use via keywords (actionA, actionB, actionC, actionD).

That is a Keyword-Driven Framework.


Create a Keyword-Driven Framework


In the example below, you will know about the concept of how to implementing a simple keyword-driven framework with a practical case.


Consider we want to test the login functionality of automatedtestingwithtuyen.com.

Login of automationtestingwithtuyen.com

For simple, we can write multiple methods in the main test case, in which each test case will test certain functionality. For opening the login page, there could be one method, for input email and password, there could be methods, for click on Log In button, there could be another method, etc.


Step 1: Prepare test cases in data files with keywords


The step definitions and related keywords table:


The test cases with keywords:

Step 2: Define the test actions


This is where we implement the function code of each method, of how each interacts with SUT.

Step 3: Write a test executor


This class will read the test case data and then drive our test steps by selecting the appropriate methods to execute based on the keywords.

So in case, we add more test cases in test files (Excel, CSV, JSON, database, etc), we need to specify the actions we want to use by listing down the keywords. The test executor will read the data file, read the keywords and trigger the actions that we had already implemented.

Advantages of Keyword-Driven Testing Framework


Keyword-Driven Testing Framework offers some advantages:

  1. Once the framework is set up, manual testers or non-technical testers can easily write test scripts for automation.

  2. As data is maintained in separated files and no coding is exposed, the test scripts are easy to read and understand. Keywords & actions resemble so closely manual test cases, which become easier to write and maintain.

  3. Save time to re-implement actions of many tests. Increase further the reusability of the automation project.

  4. Any changes in the method's implementation will focus on only one class, easy to modify, maintain and expend.


Disadvantages of Keyword-driven Testing Framework


Some drawbacks that we can face:

  1. Quality of the test depends on automation skills of implementing team members.

  2. Another tester is required to have great expertise over the scripting language of the test tool so that he/she can successfully create customized functions and utilities required for the particular application.


Conclusion

  1. A Keyword-Driven testing is a scripting technique that uses data files to contain the keywords related to the application being tested.

  2. In Keyword-Driven framework, input data can be stored in single or multiple data sources like XLS, XML, CSV, and databases.

  3. To create a test case in which steps are using the same actions from other steps,

  4. Keyword-Driven Testing Framework resolves this issue by implementing the action just one time and using the keyword to trigger the related action.

  5. Drawback of this method is that it is depended on automation skills.


294 views0 comments

Recent Posts

See All

Commentaires


bottom of page