A Keyword Driven Framework has all operations and instructions written in an external Excel file.
The basic working of the Keyword Driven Framework is to divide the Test Case into four or five different parts depending on your preference
-
Test Step: Small description of the Test Step
-
Locator name: Name of the locator like id, className etc
-
Locator value: Value of the identifier
-
Action: Name of the action such as click, getText, sendkeys etc.
-
Value: Data to be entered like Admin as username
Below is the list of common components that you would required to achieve the task:
-
Excel Sheet: This keeps most of the data for Keyword Driven which is needed for the test like parts mentioned above
-
Base Java Class: Browser initialization goes here
-
Properties Class: Properties file initialization goes here
-
Tests.java: To run tests using testng
-
Config.properties: browser name, url, username, password) in case excel file does not have them
-
Execution Engine: It contains all the code to drive the test from Excel sheet, Function Lib and Properties file.
Let just understand this concept with the help of the framework I have created for the demo of Open MRS application.
Consider that you have to automate a flow where you would need to do the following things:
-
Open a Browser
-
Navigate to URL
-
Enter Username
-
Enter Password
-
Click on LogIn button
-
Verify Login Successful
-
Select Location
-
Get Homepage header text
-
Close the Browser
Step1: To design a KDF, first identify all the actions to be performed.
Step 2: Once all actions are identified, the next step is to map them in an excel sheet
Step 3: After that, create a project in IDE and all the dependencies in pom.xml file
Step 4: Place created excel file under a new package
Step 5: Create config.properties, a base file(for browser and properties initialization), KeywordEngine(containing the implementation of keywords and test cases) and a testNG class to for the execution of test cases. Place all of them in separate packages
- Selenium
- TestNG
- Maven
- Java SE 11+
- Intellij IDEA
- Excel File
- Clone this repository to your local computer using git clone
- Install Java Development Kit - Set your JAVA_HOME environment variable to point to Java folder and add the JDK's bin folder to your path environment variable.
- Install Maven - add Maven's bin folder to your path environment variable.
Confirm installations and paths are setup in a terminal
mvn -v
java -version
- Open folder in Intellij IDEA
- Navigate to POM.xml file, right click and click reload
- Navigate to Tests.java inside src/test/java/com/qa/mrs/keyword/tests/Tests.java
- Run the file
There are many approaches to implement keyword driven framework but I have chosen this one.
Feel free to reach out on https://www.linkedin.com/in/javeria-nadeem-664375188/