Frameworks help to structure our code and make the maintenance process easy. Without frameworks we will place all our code and data in same place which is neither re-usable nor readable. Using frameworks provides beneficial outcomes like increase code re-usage, higher portability, reduced script maintenance cost, etc.
There are mainly three types of frameworks created by Selenium WebDriver to automate manual test cases. Based on the requirements of the project any of the below frameworks can be implemented:
In data driven framework all of our test data is generated from some external files like excel, csv, XML or some database table. Selenium Webdriver Data-Driven Framework is where test input and output values are from data files (ODBC sources, CVS files, Excel files, and DAO objects) and are loaded into variables in captured or manually coded scripts.
In keyword driven test framework, all the operations and instructions are written in some external file like excel worksheet. In this framework, keywords are developed which are equal to a unit level functionality. It is an independent framework which performs automation based on the keywords specified in the excel sheet. Based on the type of application, the number of keywords will be increased to handle different functionalities. Keyword driven test framework is a 5-step framework as described below:
Step 1)
Step 2)
Step 3) ReadExcelFile.java will pass this data to the driver script Execute.java
Step 4)
NOTE: You may think why we need to create an object repository. The answer, it helps in code maintenance. For example, we are using a button with name = btnlogin in 10 different test cases. In future, the developer decides to change the name from btnlogin to submit. You will have to make change in all the 10 test cases. In case of an object repository, you will make change just once in the repository.
Step 5)
Hybrid Test framework is a concept where we are using the advantage of both Keyword and data driven framework.
Here for keywords we will use excel files to maintain test cases and for test data we can use data provider of TestNG framework.
Here in our hybrid framework we don't need to change anything in Keyword driven framework, here we just need to replace ExecuteTest.java file with HybridExecuteTest.java file.
This ‘HybridExecuteTest.java’ file has all the code for keyword driven with data provider concept.
Fill the below form to download Java files