Recent from talks
Nothing was collected or created yet.
Keyword-driven testing
View on WikipediaKeyword-driven testing, also known as action word based testing (not to be confused with action driven testing), is a software testing methodology suitable for both manual and automated testing. This method separates the documentation of test cases – including both the data and functionality to use – from the prescription of the way the test cases are executed. As a result, it separates the test creation process into two distinct stages: a design and development stage, and an execution stage. The design substage covers the requirement analysis and assessment and the data analysis, definition, and population.
Overview
[edit]This methodology uses keywords (or action words) to symbolize a functionality to be tested, such as Enter Client. The keyword Enter Client is defined as the set of actions that must be executed to enter a new client in the database. Its keyword documentation would contain:
- the starting state of the system under test (SUT)
- the window or menu to start from
- the keys or mouse clicks to get to the correct data entry window
- the names of the fields to find and which arguments to enter
- the actions to perform in case additional dialogs pop up (like confirmations)
- the button to click to submit
- an assertion about what the state of the SUT should be after completion of the actions
Keyword-driven testing syntax lists test cases (data and action words) using a table format (see example below). The first column (column A) holds the keyword, Enter Client, which is the functionality being tested. Then the remaining columns, B-E, contain the data needed to execute the keyword: Name, Address, Postcode and City.
| A | B | C | D | E |
|---|---|---|---|---|
| . | Name | Address | Postcode | City |
| Enter Client | Jane Smith | 6 High Street | SE25 6EP | London |
To enter another client, the tester would create another row in the table with Enter Client as the keyword and the new client's data in the following columns. There is no need to relist all the actions included.
In it, you can design your test cases by:
- Indicating the high-level steps needed to interact with the application and the system in order to perform the test.
- Indicating how to validate and certify the features are working properly.
- Specifying the preconditions for the test.
- Specifying the acceptance criteria for the test.
Given the iterative nature of software development, the test design is typically more abstract (less specific) than a manual implementation of a test, but it can easily evolve into one.
Advantages
[edit]Keyword-driven testing reduces the sensitivity to maintenance caused by changes in the System/Software Under Test (SUT). If screen layouts change or the system is migrated to another OS hardly any changes have to be made to the test cases: the changes will be made to the keyword documentation, one document for every keyword, no matter how many times the keyword is used in test cases, and it implies a deep process of test design.
Also, due to the very detailed description of the way of executing the keyword (in the keyword documentation) the test can be performed by almost anyone. Thus keyword-driven testing can be used for both manual testing and automated testing.[1]
Furthermore, this approach is an open and extensible framework that unites all the tools, assets, and data both related to and produced by the testing effort. Under this single framework, all participants in the testing effort can define and refine the quality goals they are working toward. It is where the team defines the plan it will implement to meet those goals. And, most importantly, it provides the entire team with one place to go to determine the state of the system at any time.
Testing is the feedback mechanism in the software development process. It tells you where corrections need to be made to stay on course at any given iteration of a development effort. It also tells you about the current quality of the system being developed. The activity of implementing tests involves the design and development of reusable test scripts that implement the test case. After the implementation, it can be associated with the test case.
Implementation is different in every testing project. In one project, you might decide to build both automated test scripts and manual test scripts.[2] Designing tests, instead, is an iterative process. You can start designing tests before any system implementation by basing the test design on use case specifications, requirements, prototypes, and so on. As the system becomes more clearly specified, and you have builds of the system to work with, you can elaborate on the details of the design. The activity of designing tests answers the question, "How am I going to perform the testing?" A complete test design informs readers about what actions need to be taken with the system and what behaviors and characteristics they should expect to observe if the system is functioning properly.
A test design is different from the design work that should be done in determining how to build your test implementation.
Methodology
[edit]The keyword-driven testing methodology divides test process execution into several stages:
- Model basis/prototyping: analysis and assessment of requirements.
- Test model definition: on the result of requirements assessment, approach an own software model.
- Test data definition: on the basis of the defined own model, start keyword and main/complement data definition.
- Test preparation: intake test basis etc.
- Test design: analysis of test basis, test case/procedure design, test data design.
- Manual test execution: manual execution of the test cases using keyword documentation as execution guideline.
- Automation of test execution: creation of automated script that perform actions according to the keyword documentation.
- Automated test execution.
Definition
[edit]A Keyword or Action Word is a defined combination of actions on a test object which describes how test lines must be executed. An action word contains arguments and is defined by a test analyst.
The test is a key step in any process of development and shall to apply a series of tests or checks to an object (system / SW test — SUT). Always remembering that the test can only show the presence of errors, not their absence. In the RT system test, it is not sufficient to check whether the SUT produces the correct outputs. It must also verify that the time taken to produce that output is as expected. Furthermore, the timing of these outputs may also depend on the timing of the inputs. In turn, the timing of future inputs applicable is determined from the outputs.[2]
Automation of the test execution
[edit]The implementation stage differs depending on the tool or framework. Often, automation engineers implement a framework that provides keywords like “check” and “enter”.[1] Testers or test designers (who do not need to know how to program) write test cases based on the keywords defined in the planning stage that have been implemented by the engineers. The test is executed using a driver that reads the keywords and executes the corresponding code.
Other methodologies use an all-in-one implementation stage. Instead of separating the tasks of test design and test engineering, the test design is the test automation. Keywords, such as “edit” or “check” are created using tools in which the necessary code has already been written. This removes the necessity for extra engineers in the test process, because the implementation for the keywords is already a part of the tool. Examples include GUIdancer and QTP.
Pros
[edit]This section may contain original research. (September 2012) |
- Maintenance is low in the long run:
- Test cases are concise
- Test cases are readable for the stakeholders
- Test cases are easy to modify
- New test cases can reuse existing keywords more easily
- Keyword re-use across multiple test cases
- Not dependent on a specific tool or programming language
- Division of Labor
- Test case construction needs stronger domain expertise - lesser tool / programming skills
- Keyword implementation requires stronger tool/programming skill - with relatively lower domain skill
- Abstraction of Layers
Cons
[edit]This section may contain original research. (September 2012) |
- Longer time to market (as compared to manual testing or record and replay technique)
- Moderately high learning curve initially
See also
[edit]References
[edit]External links
[edit]Keyword-driven testing
View on GrokipediaFundamentals
Definition and Principles
Keyword-driven testing is a software testing methodology that employs predefined keywords to define and execute test cases, representing specific actions or verifications in a structured format suitable for both manual and automated testing.[4] This approach organizes test cases into tables or spreadsheets, where keywords such as "click" or "verifyText" correspond to predefined functions or scripts, enabling a clear separation between test specifications and their underlying implementation.[3] As a test case specification technique, it supports the development of automation frameworks by abstracting complex scripting into reusable components.[5] A core principle of keyword-driven testing is the decoupling of test logic from technical implementation details, allowing non-technical stakeholders, such as business analysts or domain experts, to author and maintain test cases without deep programming knowledge.[6] Keywords act as high-level commands that map directly to modular scripts or functions in a library, fostering reusability and reducing redundancy across multiple test scenarios.[4] This modularity promotes maintainable test structures, where changes to underlying automation affect only the keyword mappings rather than individual test cases.[3] For instance, a simple test case might be represented in a tabular format with columns for Keyword, Object, and Parameter, as shown below:| Keyword | Object | Parameter |
|---|---|---|
| openBrowser | Chrome | N/A |
| navigateTo | URL | https://example.com |
| verifyText | Header | "Welcome" |
| closeBrowser | N/A | N/A |
Historical Development
Keyword-driven testing emerged in the 1990s as a response to the limitations of linear scripting in early test automation efforts, which often resulted in brittle and hard-to-maintain test cases due to their sequential, code-heavy nature. This approach built on modular test automation principles, allowing testers to abstract test steps into reusable components rather than writing extensive scripts for each scenario. The methodology drew initial influence from action-word-based practices in manual testing during the 1980s and 1990s, where testers documented procedures using descriptive action terms to improve clarity and reusability in test plans.[7][8] A pivotal milestone occurred in the mid-1990s when Hans Buwalda developed the foundational concepts of what became known as action-based testing, a precursor to modern keyword-driven frameworks. In 1994, Buwalda originated this method, using spreadsheets to define tests via keywords and arguments, separating test logic from implementation to handle complex, changing requirements. He formalized the approach in publications, including a 1996 paper on "Automated Testing with Action Words: Abandoning Record & Playback," which advocated abandoning rigid record-and-playback tools in favor of keyword modularity. By 2001-2002, Buwalda presented the technique at the EuroSTAR conference, gaining industry recognition and leading to its adoption in commercial tools.[9][10][11] The early 2000s saw keyword-driven testing integrated into proprietary tools, notably Mercury Interactive's QuickTest Professional (QTP), which introduced a Keyword View in version 8.0 released in late 2004, enabling users to build tests visually using predefined keywords for actions like clicks and verifications. This feature, now part of HP Unified Functional Testing (UFT), popularized the methodology in enterprise environments by simplifying automation for non-programmers. Open-source advancements followed with the release of Robot Framework in 2008, which provided a keyword-driven structure for acceptance testing and further democratized the approach through its extensible library system.[12][13] By the 2010s, keyword-driven testing evolved to align with agile methodologies and continuous integration (CI) practices, facilitating faster feedback loops in iterative development. Frameworks like Robot were adapted for CI tools such as Jenkins, allowing automated execution of keyword-based suites in DevOps pipelines, as demonstrated in industrial automation testing standards. Post-2020, the methodology has incorporated broader AI and machine learning integrations in test automation to improve efficiency and coverage.[14][15][16]Key Components
Keywords and Actions
In keyword-driven testing, keywords serve as the fundamental building blocks that represent specific actions or operations within test scripts, allowing testers to abstract complex functionalities into reusable terms. Keywords are typically categorized into three main types: high-level, low-level, and custom. High-level keywords encapsulate broader business processes or user workflows, such as "login" or "completePurchase," which often combine multiple lower-level actions to simulate end-to-end scenarios. Low-level keywords focus on granular interactions with the application under test, such as "enterText" or "clickButton," corresponding to basic UI manipulations like inputting data or triggering events. Custom keywords are user-defined extensions tailored to domain-specific needs, enabling teams to create specialized actions beyond standard libraries, such as "validatePaymentGateway" for e-commerce testing.[17][18][4] The keyword mapping process involves linking these abstract terms to concrete implementations, such as scripts, functions, or APIs, to translate high-level test descriptions into executable code. This mapping is often documented in a centralized repository, like an Excel sheet or a dedicated library file, where each keyword is associated with its underlying logic; for instance, the keyword "clickButton" might map directly to Selenium'sclick() method, including parameters for element locators and optional waits. During test execution, a driver script or framework engine interprets the mapped keywords sequentially, invoking the corresponding code while handling any dependencies like object repositories for UI elements. This separation ensures that changes to the underlying implementation (e.g., updating a UI selector) only require modifying the mapping, without altering test cases.[17][2][4]
Best practices for keyword creation emphasize modularity and robustness to enhance maintainability. Reusability is achieved by designing keywords as independent, self-contained units that can be applied across multiple test scenarios, potentially reducing script duplication by up to 60%. Parameterization allows keywords to accept dynamic inputs, such as variables for usernames or URLs (e.g., login(username, [password](/page/Password))), enabling flexible adaptation to varying test data without rewriting the keyword itself. Error handling should be integrated within keywords, including try-catch blocks, validation checks, and logging mechanisms to gracefully manage failures like element not found exceptions, ensuring reliable execution and clear reporting.[18][19][17]
A typical keyword library structure organizes these elements in a tabular format for clarity and ease of maintenance, often using spreadsheets or framework-specific files. The following example illustrates a simple keyword library excerpt:
| Keyword | Description | Parameters | Associated Code Snippet (Pseudocode) |
|---|---|---|---|
| openBrowser | Launches a web browser instance | browserType (e.g., chrome) | driver = new WebDriver(browserType); driver.get(""); |
| enterText | Inputs text into a specified field | locator, textValue | driver.findElement(locator).sendKeys(textValue); |
| clickButton | Clicks on a button element | locator | driver.findElement(locator).click(); |
| login | Performs complete login workflow | username, password | enterText(usernameField, username); enterText(passwordField, password); clickButton(loginBtn); |
Test Case Structure
In keyword-driven testing, test cases are constructed in a structured, often tabular format to separate test logic from implementation details, enabling non-technical users to author and maintain them. Typically, these test cases are organized using spreadsheets like Excel sheets, where each row represents a test step and columns capture essential elements such as the keyword (action to perform), object locator (identifier for the UI element, e.g., XPath or ID), input data (parameters for the action), and expected result (verification criteria).[17][20][21] Key components of a test case include the overall test scenario (a high-level description of the functionality being tested, such as user authentication), preconditions (initial setup actions like launching the application or navigating to a base URL), postconditions (cleanup steps such as logging out or closing the browser), and the sequencing of keywords that define the step-by-step flow. This sequencing ensures linear execution unless modified by control structures, with each keyword invoking a predefined action from the keyword library.[17][20] For handling complex cases, test cases incorporate control keywords to manage flow, such as "if" for conditional branching based on prior outcomes or "loop" (e.g., "FOR" in frameworks like Robot Framework) for repeating sequences over datasets or iterations. These control keywords allow test cases to adapt to dynamic scenarios without embedding programming logic directly into the structure.[22] A representative example is a login test case for a web application, structured in a table as follows:| Step | Keyword | Object Locator | Data | Expected Result |
|---|---|---|---|---|
| 1 | Open Browser | N/A | Chrome | Browser window opens |
| 2 | Navigate To | N/A | https://example.com/login | Login page loads |
| 3 | Input Text | username_field (ID) | [email protected] | Username field populated |
| 4 | Input Text | password_field (ID) | password123 | Password field populated |
| 5 | Click | login_button (XPath) | N/A | User dashboard displays |
| 6 | Verify Text | welcome_message (ID) | Welcome, Test User | Welcome message matches |
| 7 | Close Browser | N/A | N/A | Browser closes |
Implementation and Methodology
Building a Keyword Library
Building a keyword library involves creating a centralized repository of reusable keywords that represent specific actions or operations in the application under test, serving as the foundational building blocks for keyword-driven testing frameworks.[23] This library enables testers to compose test cases by sequencing keywords without delving into underlying implementation details, promoting modularity and separation of concerns between test logic and execution. According to ISO/IEC/IEEE 29119-5 (2024 edition), keywords are defined by identifying sets of actions expected to occur frequently, ensuring they are named naturally and documented with parameters for clarity and reusability.[23] The process of constructing a keyword library begins with identifying common actions through analysis of test requirements, exploratory testing, or consultation with domain experts to pinpoint reusable operations such as navigation, verification, or data manipulation.[23] Next, developers create scripts or functions for each keyword, typically implementing low-level interactions with the system under test in a programming language like Python or Java, while higher-level composite keywords combine these to form more abstract actions.[24] Documentation follows, recording each keyword's name, description, parameters, expected outcomes, and usage examples in a structured format such as tables or resource files to facilitate understanding across teams.[25] Finally, version control is integrated using tools like Git to track changes, manage dependencies, and enable rollback, ensuring the library evolves alongside the application.[24] Organization of the keyword library emphasizes categorization to enhance accessibility and scalability, often grouping keywords by application module—such as user interface (UI) elements like "click_button" or application programming interface (API) calls like "send_request"—or by layers like domain-specific versus test interface actions.[26] Hierarchical structures, including base keywords for atomic operations and composite ones for sequences, support this organization to accommodate new keywords without disrupting existing structures.[23] This modular approach, as seen in frameworks like Robot Framework, permits easy import of libraries via settings files, fostering extensibility for diverse testing needs.[24] In practice, the library is stored externally, such as in resource files or databases, independent of specific test cases to maximize reuse. The 2024 edition of ISO/IEC/IEEE 29119-5 enhances library specifications with an initial list of generic technical keywords (e.g., "inputData", "checkValue") and emphasizes hierarchical keywords at various abstraction levels.[27][23] Maintenance practices focus on keeping the library aligned with application evolution, involving regular reviews—such as monthly audits—to update keywords for UI changes or new features, deprecate obsolete ones by marking them with warnings or removing them after impact analysis, and enforce consistency through a dedicated authority or peer review process.[23] Cross-references track keyword usage across test cases, minimizing ripple effects from modifications, while continuous support requires allocated staff, budget, and training to handle ongoing refinements.[23] In agile environments, this modularity reduces overall maintenance effort by localizing changes to affected keywords rather than entire test suites.[25] Challenges in library development include balancing abstraction levels, where overly low-level keywords increase complexity and high-level ones may lack precision, potentially leading to verbose test cases or implementation mismatches.[26] Avoiding over-generalization is critical, as broad keywords like "select" can introduce redundancy or ambiguity if not scoped properly, complicating maintenance and requiring careful initial design to ensure uniqueness and specificity.[25] Additionally, initial setup demands significant effort in identification and scripting, with risks of uncoordinated changes causing conflicts if version control and reviews are not rigorously applied.[28]Executing Tests
In keyword-driven testing, the execution process begins with a test execution engine or parser that reads the test case, typically structured as a table or sequence of keywords with associated parameters. This engine interprets the keywords by mapping them to predefined scripts or executable code stored in a keyword library, where each keyword corresponds to a specific action or function. The tests then proceed sequentially, invoking the mapped scripts in the order specified, which allows for modular and repeatable execution across different test scenarios. Results are logged throughout, capturing outcomes such as pass/fail status, timestamps, and execution durations for each keyword step.[23] For automated execution, the framework integrates with automation drivers for web or UI interactions, where the tool bridge connects high-level keywords to low-level operations such as locating elements, handling inputs, and navigation. This integration enables the execution of actions including synchronization with application responses, assertions to verify expected states (e.g., element presence or text matching), and real-time reporting mechanisms that generate summaries or detailed logs in formats like HTML or XML. The same keyword structure supports manual execution, where testers follow the sequence using a manual test assistant tool to perform and record steps without automation, though automated runs require a central driver script to orchestrate the flow and handle environment setup.[23][7] Error handling occurs at the keyword level, where the execution engine detects exceptions such as unimplemented keywords, timeouts, or assertion failures, marking the affected step as blocked or failed while allowing continuation or cleanup via predefined exception handlers. Failures trigger detailed reporting, including error messages, stack traces, and screenshots if applicable, to facilitate debugging and incident logging without halting unrelated test portions. This granular approach ensures traceability and supports partial test completion even in the presence of isolated issues.[23][25]Advantages and Challenges
Benefits
Keyword-driven testing offers enhanced maintainability by allowing modifications to the underlying implementation of a keyword in a centralized library, which propagates across all associated test cases without requiring updates to individual scripts.[29] This modularity reduces sensitivity to application changes, minimizing overall maintenance effort compared to monolithic scripts.[29] Studies on evolving keyword-driven test suites have demonstrated potential reductions of approximately 70% in test code changes, further underscoring its efficiency in long-term upkeep.[30] Reusability is a core strength, as keywords—defined as modular, generic components—can be applied across multiple test cases, projects, or even similar systems, promoting portability and reducing redundancy in test development.[29] For instance, a keyword encapsulating a common action like "login" can be reused in various scenarios, streamlining the creation of comprehensive test suites without duplicating effort.[25] The approach enhances accessibility for non-programmers, such as business analysts or domain experts, by employing English-like keywords that abstract technical details, enabling them to author and edit test cases without requiring coding expertise.[29] This lowers the barrier to participation in testing activities, allowing contributions from stakeholders who understand business requirements but lack programming skills.[31] Improved collaboration arises from the readable, domain-oriented nature of keyword-driven test cases, which bridge the gap between technical testers and business-level experts by using terminology familiar to all parties for review and validation.[29] Such clarity facilitates joint efforts in test design and ensures alignment on business correctness without necessitating deep technical knowledge from non-developers.[25] Scalability is supported through efficient expansion of test suites, as new cases can be composed from an existing keyword library with minimal additional implementation, leading to cost and schedule savings in both manual and automated contexts.[29] This structure accommodates growing project needs without proportional increases in development or maintenance overhead.[29]Limitations
One significant limitation of keyword-driven testing is the high initial setup effort required to develop a comprehensive keyword library. Creating reusable, application-independent keywords demands substantial time and expertise, often delaying the implementation of automated tests compared to simpler scripting approaches.[28] This upfront investment can extend project timelines, especially for large-scale applications where extensive coverage is needed.[32] To mitigate this, teams can prioritize developing a minimal viable library focused on core functionalities and leverage open-source tools for pre-built keywords, gradually scaling as benefits accrue.[25] Another drawback is the performance overhead introduced by the interpretation layer in keyword-driven frameworks. The need to parse and map keywords to underlying scripts during execution can result in slower test runs compared to direct code execution, particularly for GUI-intensive tests where keyword failures trigger retries and timeouts.[33] For instance, failing graphical user interface keywords may significantly prolong overall execution time unless optimized.[33] Mitigation strategies include setting appropriate time limits for keywords and optimizing the framework's parsing efficiency through streamlined library design.[33] Keyword-driven testing also exhibits limited flexibility for handling complex logic, such as highly conditional or dynamic scenarios, without developing custom keywords. This approach struggles with intricate decision trees or asynchronous behaviors, often requiring additional low-level scripting that undermines the framework's abstraction benefits.[28] Poor handling of such cases can lead to brittle tests that fail unexpectedly during application evolution.[30] To address this, practitioners can balance high-level and low-level keywords carefully, incorporating conditional logic within the library while avoiding over-customization.[25] The quality of the keyword library heavily influences the framework's effectiveness, as poorly designed keywords—such as those with redundancy or tight coupling to specific applications—can create ongoing maintenance challenges. Inadequate libraries amplify fragility, making tests prone to breakage from even minor software under test changes.[30] This dependency often results in higher long-term costs if keywords lack modularity.[32] Mitigation involves enforcing design principles like reusability and independence during library creation, coupled with regular refactoring to ensure robustness.[25] Finally, keyword-driven testing presents a learning curve for advanced customization, necessitating proficiency in scripting languages and framework integration for testers. Non-technical users may initially struggle with extending libraries or debugging keyword mappings, limiting adoption in diverse teams.[28] This barrier can slow progress, particularly in agile environments requiring rapid adaptations.[25] To overcome it, organizations should provide targeted training on tool-specific scripting and encourage knowledge transfer from experienced architects.[32]Tools and Frameworks
Popular Tools
Several popular tools and frameworks facilitate keyword-driven testing by providing built-in support for keyword libraries, intuitive interfaces for test creation, and features like detailed reporting and cross-platform execution, which are key criteria for tool selection in this methodology.[34] Robot Framework is an open-source, Python-based test automation framework that inherently employs a keyword-driven approach, using a tabular format to define tests with extensible keywords for web, mobile, and desktop applications. It emphasizes ease of keyword creation through user-defined libraries and offers rich reporting via HTML outputs, logs, and screenshots, while supporting cross-platform testing on Windows, macOS, and Linux.[35] Micro Focus Unified Functional Testing (UFT), now part of OpenText, is a commercial tool that supports keyword-driven testing through its visual Keyword View, enabling users to build tests by dragging and dropping keywords without extensive scripting. It includes advanced features for keyword management, such as reusable function libraries, and provides comprehensive reporting with dashboards and integration options for CI/CD pipelines, alongside support for testing desktop, web, mobile, and API applications across multiple platforms.[36][37] Tricentis Tosca is a commercial, model-based test automation tool that incorporates keyword-driven testing with visual, reusable test modules and risk-based optimization. It supports codeless keyword creation for end-to-end testing across web, mobile, API, and desktop applications, featuring AI-assisted test design, detailed execution reports, and seamless CI/CD integration for agile environments as of 2025.[2][35] Selenium, an open-source framework primarily for web testing, is frequently adapted for keyword-driven testing by integrating with wrapper libraries or custom frameworks that abstract actions into reusable keywords, simplifying test maintenance for browser-based applications. This combination enhances keyword creation via predefined action words and supports reporting through plugins like Allure or ExtentReports, with cross-browser and cross-platform compatibility via drivers for Chrome, Firefox, and more.[17][38] Other notable tools include Katalon Studio, which offers built-in keyword support for web, API, mobile, and desktop testing, featuring a low-code interface for easy keyword development, integrated reporting, and broad platform coverage.[39] TestComplete by SmartBear provides keyword-driven testing via its drag-and-drop Keyword Tests, with strong extensibility, detailed execution reports, and support for multiple application types across platforms.[40] Appium, an open-source tool for mobile automation, extends keyword-driven capabilities through integrations with frameworks like Robot Framework, allowing keyword-based tests for iOS and Android apps with reporting via external tools and cross-device support.[18] TestRigor, an AI-powered codeless automation tool, enables keyword-driven testing using plain English commands for web, mobile, and API testing, with self-healing capabilities, built-in reporting, and support for cross-platform execution as of 2025.[41][18]Integration Examples
In Robot Framework, keyword-driven testing can be implemented by defining custom keywords that interact with web elements via the SeleniumLibrary. For instance, a keyword named "Verify Login" might encapsulate the process of entering credentials and asserting successful authentication on a login page. This keyword could be structured as follows, using arguments for username and password:*** Keywords ***
Verify Login
[Arguments] ${username} ${password}
Input Text id=username ${username}
Input Text id=password ${password}
Click Button id=login
Page Should Contain Welcome
[Teardown] Close Browser
*** Keywords ***
Verify Login
[Arguments] ${username} ${password}
Input Text id=username ${username}
Input Text id=password ${password}
Click Button id=login
Page Should Contain Welcome
[Teardown] Close Browser
Input Text and Click Button on locators such as IDs or XPaths. A test suite can then invoke this keyword within a test case, such as:
*** Test Cases ***
Valid Login Test
Open Browser http://example.com/login chrome
Verify Login demo mode
*** Test Cases ***
Valid Login Test
Open Browser http://example.com/login chrome
Verify Login demo mode
robot test_suite.robot executes the test, producing logs and reports that detail keyword execution and outcomes.[42][43]
For Selenium integration in a Java-based environment, a keyword-driven framework can be built using TestNG for test execution and management. The framework typically includes an object repository for element locators, a keyword library class implementing actions like click or sendKeys, and an execution engine that maps Excel-based test steps to these methods. A Java keyword driver class, such as ActionKeywords, might define methods corresponding to keywords:
public class ActionKeywords {
public void openBrowser(String browser) {
if (browser.equals("firefox")) {
driver = new [FirefoxDriver](/page/Firefox)();
}
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
public void inputUsername(String username) {
driver.findElement(By.id("log")).sendKeys(username);
}
public void clickLogin() {
driver.findElement(By.id("login")).click();
}
}
public class ActionKeywords {
public void openBrowser(String browser) {
if (browser.equals("firefox")) {
driver = new [FirefoxDriver](/page/Firefox)();
}
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
public void inputUsername(String username) {
driver.findElement(By.id("log")).sendKeys(username);
}
public void clickLogin() {
driver.findElement(By.id("login")).click();
}
}
@Test in TestNG organize suites, allowing parallel execution and reporting. This setup automates a login flow by sequencing keywords like openBrowser, inputUsername, inputPassword, and clickLogin.[44]
In API testing, keywords can handle REST calls using libraries like RequestsLibrary in Robot Framework, enabling declarative test scripts for endpoints. For example, a keyword for a POST request to create a user might be defined as:
*** Keywords ***
Create User
[Arguments] ${user_data}
POST /users ${user_data}
Response Status Code Should Be 201
Output ${response.json()}
*** Keywords ***
Create User
[Arguments] ${user_data}
POST /users ${user_data}
Response Status Code Should Be 201
Output ${response.json()}
{"name": "John", "email": "[email protected]"}, and verifying the response. Similarly, a GET keyword like Retrieve User /users/1 Integer response body id 1 asserts specific values in the JSON response. These keywords abstract HTTP methods and validations, allowing suites to test full API workflows without scripting low-level details. While tools like Postman support scripting extensions via Newman CLI for keyword-like chaining in collections, Robot Framework's tabular syntax provides native keyword support for REST interactions.[45]
Keyword-driven tests can integrate into CI/CD pipelines using Jenkins, where Robot Framework suites are executed via plugins, and results are reported through Allure for visual dashboards. In Jenkins, the Robot Framework plugin schedules builds triggered by Git commits, running commands like robot --listener allure_robotframework:allure_results tests/. The allure-robotframework listener generates XML outputs during execution, which Allure merges into HTML reports accessible post-build. For example, a Jenkins pipeline script might include stages for checkout, test execution (sh 'robot test_suite.robot'), and reporting (allure serve allure_results), providing metrics like pass/fail rates and step traces. This setup ensures automated regression testing with historical trend analysis in Allure.[46]
A real-world scenario involves an e-commerce login test using hybrid keywords across web and mobile platforms in Robot Framework, leveraging SeleniumLibrary for web and AppiumLibrary for mobile. A shared keyword like "Login To E-Commerce" accepts a platform argument:
*** Keywords ***
Login To E-Commerce
[Arguments] ${platform} ${username} ${password}
IF '${platform}' == 'web'
Open Browser [https://shop.example.com/login](/page/HTTPS) chrome
SeleniumLibrary.Input Text id=email ${username}
ELSE IF '${platform}' == 'mobile'
Open Application [http://localhost:4723/wd/hub](/page/Localhost) platformName=Android
AppiumLibrary.Input Text id=email ${username}
END
Input Text id=password ${password}
Click Element id=login-button
Page Should Contain Element class=welcome-message
*** Keywords ***
Login To E-Commerce
[Arguments] ${platform} ${username} ${password}
IF '${platform}' == 'web'
Open Browser [https://shop.example.com/login](/page/HTTPS) chrome
SeleniumLibrary.Input Text id=email ${username}
ELSE IF '${platform}' == 'mobile'
Open Application [http://localhost:4723/wd/hub](/page/Localhost) platformName=Android
AppiumLibrary.Input Text id=email ${username}
END
Input Text id=password ${password}
Click Element id=login-button
Page Should Contain Element class=welcome-message
Login To [E-Commerce](/page/E-commerce) web [email protected] pass123 followed by mobile execution, ensuring consistent behavior like secure authentication and session handling in an online store. This hybrid approach reuses keywords while adapting locators for web (e.g., CSS selectors) and mobile (e.g., accessibility IDs).[47]
Comparisons
With Data-Driven Testing
Data-driven testing is an automation approach that separates test data from the underlying test scripts, enabling the execution of the same test logic with multiple sets of input values to validate functionality across varied scenarios.[48] This method typically stores data in external files such as spreadsheets, CSV files, or databases, which the script reads to parameterize tests and reduce code duplication.[49] By focusing on data variation rather than action definition, it supports exhaustive validation of inputs, such as testing form submissions with diverse user details.[50] In contrast to keyword-driven testing, which abstracts reusable actions through predefined keywords to promote modularity and accessibility for non-technical users, data-driven testing prioritizes the parameterization of inputs to cover edge cases and boundary conditions within a fixed script structure.[51] For instance, keyword-driven testing might define a login action via keywords like "Enter Username" and "Click Submit," executed once per test case, whereas data-driven testing applies the same login script to numerous credential sets sourced from a CSV file to simulate different users.[48] This distinction highlights keyword-driven testing's emphasis on action reusability across diverse scenarios, while data-driven testing excels in scenarios requiring broad input coverage without altering the core logic.[49] Keyword-driven testing is particularly suitable for building maintainable test suites where actions need to be shared and adapted across multiple test flows, such as e-commerce workflows involving search, add-to-cart, and checkout steps.[51] Data-driven testing, however, is ideal for applications demanding rigorous validation of data-dependent behaviors, like financial systems processing varied transaction amounts or user registrations with international formats.[50] Selecting between them depends on project needs: keyword-driven for abstraction in complex, action-heavy environments, and data-driven for efficiency in data-intensive validations. Hybrid approaches integrate both methodologies to leverage their strengths, such as using keyword-driven structures to define actions while incorporating data-driven elements like external data tables for parameterization, resulting in more comprehensive and flexible test suites.[48] For example, a hybrid login test could employ keywords for the action sequence but iterate over multiple user credentials from a data file to test authentication under various conditions, enhancing coverage without redundant scripting.[51] This combination is increasingly adopted in agile teams to balance reusability with thorough input testing.[49]With Script-Based Testing
Script-based testing, also known as linear or programmable scripting, involves directly coding test procedures in programming languages such as Java, Python, or C#, where testers write line-by-line logic to simulate user interactions, verify conditions, and handle exceptions.[52] This approach provides full programmatic control, allowing for complex conditional statements, loops, and custom functions tailored to specific application behaviors.[53] In contrast, keyword-driven testing abstracts the underlying code into reusable keywords that represent high-level actions, such as "login" or "navigate," stored in tables or external files and interpreted by a driver script.[54] The key differences lie in abstraction and accessibility: script-based testing requires programming expertise for implementation and maintenance, offering precise control but resulting in verbose, application-specific code that is less readable for non-technical stakeholders.[52] Keyword-driven testing enhances readability and enables domain experts to contribute to test design without coding, though it relies on a predefined keyword library that must map accurately to scripted implementations.[53] Trade-offs between the two highlight maintenance priorities: keyword-driven testing reduces scripting overhead by promoting reusability across tests, lowering long-term costs, but introduces interpretation overhead from the driver layer.[52] Script-based testing accelerates development for simple, one-off tests due to its directness but becomes brittle to UI changes, demanding frequent code rewrites and increasing fragility in evolving applications.[54] For scalability, keyword-driven methods better support large test suites by decoupling test logic from implementation details.[53] Migration from script-based to keyword-driven testing often involves refactoring existing scripts into modular functions that serve as keywords, enabling gradual adoption for better scalability in enterprise environments.[54] This process typically starts by identifying common patterns in scripts, extracting them into a library, and replacing direct calls with keyword references, which can reduce redundancy and improve team collaboration over time.[52] A representative example is a login test flow. In script-based testing, the procedure might be hardcoded as follows in Python using Selenium:from selenium import webdriver
driver = webdriver.Chrome()
driver.get("[https](/page/HTTPS)://example.com/[login](/page/Login)")
driver.find_element("id", "username").send_keys("user")
driver.find_element("id", "password").send_keys("pass")
driver.find_element("id", "submit").click()
assert "Welcome" in driver.page_source
driver.quit()
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("[https](/page/HTTPS)://example.com/[login](/page/Login)")
driver.find_element("id", "username").send_keys("user")
driver.find_element("id", "password").send_keys("pass")
driver.find_element("id", "submit").click()
assert "Welcome" in driver.page_source
driver.quit()
| Object | Keyword | Value |
|---|---|---|
| LoginPage | Enter | username, user |
| LoginPage | Enter | password, pass |
| LoginButton | Click | |
| WelcomePage | Verify | text, Welcome |
