In this blog, Let’s have a basic understanding of how a project structure looks and how it can be executed.
Prerequisite: Basic understanding of Java, Cucumber and Selenium is required.
Introduction:
We are going to learn standard Automation Framework, there are set of rules and corresponding tools that are used to build test cases, it is designed to build engineering functions to work more efficiently to develop automated test scripts, to organize and manage all the files and to finish all the tasks in a systematic approach using a framework.
Manual test case in Gherkin Format
First step to automation is to write manual test cases and it would be useful if it is in Gherkins format and it can be easily transferred into automation test cases.
Gherkins is a behavior-driven development and is a Plain English Language it describes test cases for a software system in a way that can be read and understood by anyone.
Given below sample Gherkins test cases.
Tools and Framework used to Automate a Project.
Selenium
Java
Cucumber BDD
Jenkins
Maven
TestNG
Framework Folder Structure in Eclipse:
In this section we will look into the clear picture, explanation and required framework and their importance of the project structure in eclipse.
pom.xml
Pom.xml for (dependencies and plugins) POM.xml stands for “Project Object Model”, XML file contains information of a project and configuration information for the maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, etc.
SRC/TEST/RESOURCES
What resources does is its a default place for java libraries and their configuration files
Configuration Properties: All hardcoded strings used to validate in test cases are given as settings in these files.
Driver: This folders holds automation drivers exe files, such as chromedriver.exe
Features: Under features it has a list of all the BDD feature files grouped by functionality
Inputdata: This folder contains data files as xls or csv which is used for data driven test cases
SRC/TEST/JAVA
Context:
TestContext
Step Definition classes have dependencies of TestContext.
TestContext is used to share a state of an object across a different scenario and different steps by holding reusable singleton instances of objects.
Test context instance is automatically created by dependencies injection framework by Pico-Container.
Test Context holds and manages following objects
Driver Manager
Page Object Manager
Scenario Context
Enum: It’s a data type and it has a predefined set of constants. For example
BrowserType
Context
Manager:
DriverManager: DriverManager creates and manages drivers instances of different types of drivers based on the requested type.
FileReaderManger: File reader manages all the file reader object used to read data driven test data file
PageObjectManager: PageObjectManager creates and manages all the page objects.
Pages:
PageObjects: Helps to map web elements with Xpath and get executed when test cases run.
Reader: Reader classes are used to read data file corresponding to the parameter carried using the ConfigFile reader and Excelreader.
ConfigFile Reader
ExcelReader
Utilities: Common utility classes used across the framework.
HandleExceptions.java - Handles exception across framework
Log.java - Common logger
Screenshots.java - Helps to take screenshot
StepDefinitions: StepDefinitions file contains the all test execution step definition grouped by functionality.
Runner: Test runner is a starting point of the test execution, you have several kinds of plugins available to setup automation test case type and create reports. We have used TestNG and our runner.
Framework Execution Flow
Allure Status Reports
Test run allure status reports will be generated by a plugin invoked in test runner. Given below sample status report.
Conclusion
This is a recommended framework to set up selenium automation projects. By following this standard we make sure our framework is good enough for future changes and scaling to new features seamlessly.
Happy Testing!!!