Basic understanding of a framework:
Before developing a framework we should step back and understand whether we need a framework or not? A framework makes our life easy. However, on the other hand to create a mature framework, time and cost is involved.
Here we are discussing about automation testing and it’s related frameworks. So to understand WHAT a basic automation framework does, we should understand the basic of automation testing.
Basic understanding of automation:
To be honest, we can achieve many things using automation. I will try to highlight almost everything to start automation.
In simple words, we automate the manual test cases using some tool. These automated test cases are written in such a way that it can be executed anytime without manual intervention. As time goes on, the automation scripts become complex and unorganized because of update, delete and insert in AUT(Application Under Test). Hence the need of framework comes into play.
Prerequisite: Features of automation framework.
Creation of first automation framework:
Here we will develop a automation framework with all the basic feature discussed above.
Prerequisite: basic knowledge of Selenium WebDriver, Java, TestNG is required.
Let’s start developing:
Landscape diagram of the framework:
2. Framework in one snip:
The representation of basic framework is described above.
- Create the project structure as shown in the project explorer.
- Create the utility files first:
- Utility.java: define all the customized function required for interacting with the objects. You can even implement WebDriver interface.
- Read Properties java file: define reading the config.properties file.
- Read excel java file: define reading excel file.
- Create config.properties file:
- Analyze and create the environment variables based on the application under test. For example: browsers, environment variables, test data path etc.
- Create or import test data: try to read the excel (or any other file format) using read excel java file.
- Create Object repository: Divide the AUT into pages or module which ever is convenient, so that it is easy to locate each element in the framework.
- Create business logic module: Again business logic are to be structured in such a way that it can be easily understandable and located. As business logic keeps changing during, we should keep updating the logic. Remember it is suggested to keep the business logic method static so that it can be easily called in the test scripts.
- At last, create the test scripts: Mimic the manual test cases as shown in the snip above. Call the business logic along with the related test data.
Hope this will be helpful, in case of any further doubt please contact me. Please do like and follow my blog for further discussions on automation.