Keyword-driven framework in selenium

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

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

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.

    Source: Safalta

    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.

Free Demo Classes

Register here for Free Demo Classes

Trending Courses

Professional Certification Programme in Digital Marketing (Batch-6)
Professional Certification Programme in Digital Marketing (Batch-6)

Now at just ₹ 49999 ₹ 9999950% off

Master Certification in Digital Marketing  Programme (Batch-12)
Master Certification in Digital Marketing Programme (Batch-12)

Now at just ₹ 64999 ₹ 12500048% off

Advanced Certification in Digital Marketing Online Programme (Batch-23)
Advanced Certification in Digital Marketing Online Programme (Batch-23)

Now at just ₹ 24999 ₹ 3599931% off

Advance Graphic Designing Course (Batch-9) : 90 Hours of Learning
Advance Graphic Designing Course (Batch-9) : 90 Hours of Learning

Now at just ₹ 19999 ₹ 3599944% off

Flipkart Hot Selling Course in 2024
Flipkart Hot Selling Course in 2024

Now at just ₹ 10000 ₹ 3000067% off

Advanced Certification in Digital Marketing Classroom Programme (Batch-3)
Advanced Certification in Digital Marketing Classroom Programme (Batch-3)

Now at just ₹ 29999 ₹ 9999970% off

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

Now at just ₹ 1499 ₹ 999985% off

WhatsApp Business Marketing Course
WhatsApp Business Marketing Course

Now at just ₹ 599 ₹ 159963% off

Advance Excel Course
Advance Excel Course

Now at just ₹ 2499 ₹ 800069% off

Latest Web Stories