Keyword-driven framework in selenium

Safalta Expert Published by: Vanshika Jakhar Updated Sat, 26 Nov 2022 12:46 AM IST

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.

    Free Demo Classes

    Register here for Free Demo Classes

    Please fill the name
    Please enter only 10 digit mobile number
    Please select course
    Please fill the email
    Something went wrong!
    Download App & Start Learning

    Source: Safalta

    Data Driven Framework: Before writing test cases, one must wait for development to be complete.

Download these Free EBooks:
1. Introduction to digital marketing
2. Website Planning and Creation

 

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 https://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.

 

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 excelData 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."
 

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.

Free Demo Classes

Register here for Free Demo Classes

Trending Courses

Master Digital Marketing Program Batch-3
Master Digital Marketing Program Batch-3

Now at just ₹ 49999 ₹ 12500060% off

Advance Digital Marketing Course (Batch-15) : 150 Hours Learning
Advance Digital Marketing Course (Batch-15) : 150 Hours Learning

Now at just ₹ 15999 ₹ 3599956% off

Super Advance Digital Marketing Course: Classroom Program at NOIDA
Super Advance Digital Marketing Course: Classroom Program at NOIDA

Now at just ₹ 29999 ₹ 9999970% off

Basic Digital Marketing Course (Batch-22): 50 Hours Live+ Recorded Classes!
Basic Digital Marketing Course (Batch-22): 50 Hours Live+ Recorded Classes!

Now at just ₹ 1499 ₹ 599975% off

Job Interview Skills Batch 7
Job Interview Skills Batch 7

Now at just ₹ 999 ₹ 999990% off

Advance Graphic Designing Course (Batch-7) : 150 Hours of Learning
Advance Graphic Designing Course (Batch-7) : 150 Hours of Learning

Now at just ₹ 12999 ₹ 2999957% off

Graphic Designing (Mobile Tools Only) Batch-17: 50 Hours Live+ Recorded Classes! 
Graphic Designing (Mobile Tools Only) Batch-17: 50 Hours Live+ Recorded Classes! 

Now at just ₹ 1499 ₹ 599975% off

Advance Excel Course
Advance Excel Course

Now at just ₹ 2499 ₹ 800069% off

Advance Excel Course with VBA
Advance Excel Course with VBA

Now at just ₹ 4499 ₹ 999955% off