Keyword-driven framework in selenium

Safalta Expert Published by: Vanshika Jakhar Updated Tue, 20 Jun 2023 12:04 PM IST

Source: Safalta

Selenium's framework assists in keeping test cases separate by separating the code from the data. Frameworks aid in the code's reuse, readability, and maintenance cost reduction. 

Boost your Skills by learning: Digital Marketing

Table of Content
What does Selenium's Keyword Driven Framework mean?
The distinction between a data-driven and a keyword-driven framework
Example of a Keyword Driven Framework Using Selenium WebDriver
Benefits of a keyword-driven testing framework
Disadvantages of Keyword-Driven Testing Framework

What does Selenium's Keyword Driven Framework mean?

All procedures and guidelines for a keyword-driven framework are documented in an external Excel file.

Let's examine the procedure to understand how it functions.

  • The automation script will read the guidelines or input data used for testing from the Excel sheet.
  • The application under test is filled out with input data.
  • Results are returned after running the test cases.
  • The Excel sheet contains the test output data.

Although the procedure is straightforward, keyword-driven testing in Selenium is carried out using a structured methodology. Let's first discuss how the keyword-driven approach differs from the data-driven approach before going further with that.


The distinction between a data-driven and a keyword-driven framework

Because there are more abstraction layers between test scripts, test data, keywords, etc., the keyword-driven framework is simple to maintain.

Data-driven frameworks are more difficult to maintain because there is only an abstraction between test data and test scripts.

  • Keyword-Driven Framework: Planning for keyword-driven frameworks must be thorough and precise. Planning is simple with a data-driven framework because only test data and test scripts are required.
  • With a keyword-driven framework, test scripts can be written before a product has finished the development process. Data Driven Framework: Before writing test cases, one must wait for development to be complete.

Example of a Keyword Driven Framework Using Selenium WebDriver

With the aid of an example, let's examine the procedures for developing a straightforward Keyword Driven Framework design. The scenario will automate a web application's entire flow.

To be an automated scenario:

1. Start a browser.

2. Go to www.browserstack.com in your browser.

3. Type in a username.

4. Type in a password.

5. Select the "Sign In" button.

6. Select the "Logout" link.

7. Exit your browser.

 

Read More: Illustration Designer jobs: Salary, Skills, and Benefits

Step 1: To design a keyword-driven framework, list all the procedures to be followed for an application's automated testing. Seven tasks must be completed in the scenario above.

Step 2: After all actions have been identified, the Excel sheet's next task is to create a keyword map table. A table in an Excel sheet called a "keyword map table" lists all the keywords that can be used in test automation projects.

Step 3: After all keywords have been found, attach the Excel spreadsheet to the project's package. By selecting the project with the right click, you can create a package called "Excel data." Go to New > Package to do this.

Step 4: Generate a fresh package called "utility." The tester will now define constants like URL, filePath, and excel data in a new class file called "Constants."

Step 5: Now, write code for each action keyword. A new package called "keyword driven" should be created. A new class file called "Action Keyword" should be created. Create methods in this class for each action keyword that was found in Excel.

Step 6: Write the code necessary to read data from an Excel sheet. Use an Apache POI library for this so that testers can use Java to read, write, and edit Microsoft Office documents.

Step 7: The following step involves creating the code to call the reader to the Excel data() method of the ReadExcelSheet class and the ActionKeywords class's methods. The following source code should be written in a new package called "execution engine" using a class called "ExecutionTest."
 

Read More: Are Visual Effects (VFX) Artist Jobs Worth
 

Benefits of a keyword-driven testing framework

Code reusability.

Platform-agnostic Test Scripts

Increased Productivity

Abstraction of applications.
 

Disadvantages of Keyword-Driven Testing Framework

Keyword administration.

lengthy planning

The ability to create test scripts.

Writing test scripts requires more time than usual.

The advantages are clear enough to demonstrate the effectiveness of Selenium's Keyword Driven Framework. By utilizing Selenium's Keyword Driven Framework, testers can get around many of the issues that arise when using other framework-based techniques.

Is the Keyword Driven Framework supported by Selenium?

Selenium's frameworks assist in keeping test cases separate by separating the code from the data. Frameworks aid in the reuse, readability, and maintenance cost reduction of the code.

What does the Keyword Driven framework aim to achieve?

The Keyword-Driven framework is a method for externalizing script-related keywords into their Object Repository.

What is an automation based on keywords?

Table-driven testing, action word-based testing, and keyword-driven testing are all examples of functional automation testing frameworks.

Latest Web Stories