What is Keyword Driven Testing?

The rising demands of Agile and DevOps have changed the overall concept of traditional testing. Now, companies need testers with diverse skillsets and more experience in the field. Teams need to operate flexible automated testing tools to create maintainable and scalable UI tests instantly.

Testers use a series of operations to build automated UI tests. Each test involves keywords to simulates a user's action, such as clicking a mouse or pushing a key on the keyboard. Through a keyword-driven testing tool like TestComplete, you can create reusable automated tests through simple drag-and-drop actions, even without scripting knowledge.

What is Keyword driven testing?

Keyword-driven testing refers to a testing methodology that allows testers to separate test case design from test development. Consequently, it opens up the door for more professional input in the test automation process. It is a part of a functional automation testing framework that goes by the name table-driven testing or action word-based testing.

A Keyword-driven test comprises a collection of keywords that can be reused as similar as other tests.

A keyword sequence is a keyword containing a combination of keywords. It allows you to arrange your tests precisely as well as maintain them with less effort.

In simple terms, a keyword refers to a combination of action/s on a test object that you can implement using various tools and programming languages such as .NET or Java.

Usually, keywords or action words for each function are noted in a table format such as spreadsheets. The standard form of a Keyword driven framework is to classify a test case into four sections- Test step, object, action, and data.

  • Test Step − It includes a short description of the action that will execute on a test object.

  • Test Object − It contains the name of the web page elements like username, password, etc.

  • Action − It refers to the name of the action such as click, open browser, input, etc.

  • Test Data − Data contains values an object requires to execute any action, such as username value for the username field.

The Keyword-driven approach separates coding from test cases and test steps so that even a non-technical person can understand the automation process. It also makes it easier for a manual tester to write automation scripts. Keyword-driven testing also requires the presence of an automation tester. To make the test work, you need a well-experienced technical coder to regularly set up the test framework and update the automation code in the background.

In general, an automation team requires two manual testers and one automation coder.

Difference between Data-Driven and Keyword Driven Framework 

Keyword Driven FrameworkData-Driven Framework
Easy to manage due to the presence of more abstraction layers between test data, keywords, scripts, etc.A bit harder to manage compared to the keyword-driven framework as abstraction is the only presence between test scripts and test data.
Precise planning is required for developing frameworks.Only requires test data and test scripts, therefore planning is easy.
Testers can write test scripts before the product finished its development stage.Testers cannot write test cases before finishing the development process.

Components Required for a Keyword Driven Framework

  • Excel sheet − To store data for test cases

  • Object Repository − To store locator values of web elements

  • Function library − To create functions to perform actions

  • Test Datasheet − To store data values inside objects

  • Selenium − To set up an environment. You can also use other tools for this purpose.

  • Driver Script − To interact with test scripts

Advantages of Keyword Driven Testing

Following are the advantages of a keyword-driven testing process

  • Create UI Test easily − It allows easy creation of automated functional UI tests and handles complex scenarios without programming knowledge. Some scenarios include managing unwanted windows, accessing database information, etc.

  • Built-in automation framework − It enables you to create easy to manage and scalable, automated UI tests and separate test steps, objects, test data, and actions. You can also reuse these components even having technical knowledge.

  • Switch keyword tests to scripted tests − It allows you to convert desktop, mobile, and web keyword tests into scripted tests in a single click that contributes to rapid GUI testing. With tools like TestComplete, you can integrate various scripted languages like Jscript, VB.NET, Python, and more.

  • Reuse in other test automation projects − You can reuse keyword-driven tests in multiple projects simultaneously. It allows you to execute automated UI tests in different testing cycles much faster than other methods.

How to perform Keyword Driven Testing? 

You can conduct keyword-driven testing both manually and automated. However, mostly it is done via automated testing.

It helps in −

  • Reducing maintenance cost

  • Reusing function scripting

  • Creating better testing support and portability

  • Conduct more testing at less time

  • Avoid duplicated specifications

You can create simple, functional tests through keyword-driven testing. These tests are done at the earliest stage of the development for testing an application piece by piece. You need to record the keyword-driven test and modify or customize them as per your requirement.

You need to assign at least one action to each keyword that involves either a command, test script, or function.

Test automation framework refers to a test library that interprets the keywords when test cases are executed.

Five steps to execute a keyword-driven testing

  • Step 1 − Identify low-level and high-level keywords

  • Step 2 − Implementing keywords

  • Step 3 − Creating test cases

  • Step 4 − Creating driver scripts

  • Step 5 − Executing automation test scripts

Conclusion −

Keyword-driven testing requires intensive planning, which is time and resource-consuming. Once it’s over, the rest of the testing process is a piece of cake. You can use automated tools like selenium or HP QTP to prepare the keyword-driven framework, even if you do not have any technical knowledge.