Create framework or structure for Selenium Project

Profile picture for user ksharma

There can be several variation of Selenium Framework folder structure within different organisation. Here we will be creating Hybrid Framework which is combination of Module based and data driven framework.

Selenium tool help us to create automation scripts but; without a proper structure of the scripts it's very hard to maintain the scripts. So there is need to create a framework.

A framework provides us a structure to maintain our scripts easily and effectively. With the help of framework we can define various guidelines like coding standards, concepts, process and practice.

Below is the structure of the framework that we have created using maven.

Packages in src/main/java

Inside main you can define utilities:

utils (com.orgname.projectname.utils) 

This package will contain following class file:

  • PropertyReader.java: This contains property file read and configurations. This file will read all the parameters that we have created in the app.properties in one go.
  • DriverConfigurations.java: All driver related configurations. In Driver configurations we will create the functionality for running our test script on the expected browser.
  • ExcelReader.java: To read data from excel file.
  • XMLReader.java: To read data from xml files.
  • DatabaseReader.java: To read data from database.
  • Constants.java: The folder is integration of the java classes that store the static variables referencing to the paths, files and other environmental details.

Packages in src/test/java

  • helper (com.orgname.project.helper): Contain TestBase.java for TestNG annotations and listeners. Also contains, GenericFunctions.java for common functions.
  • pages/pageobjs (com.orgname.project.pageObjs): In the Object Repository we are storing page objects for each page individually in this package. Store objects files like HomePage.java, LoginPage.java etc.
  • testcases/tests (com.orgname.project.testcases): In this package we are storing test cases for each page. We do not define any objects in our test class. Example File: HomeTest.java, LoginTest.java

Packages and files in src/main/resources

  • app.properties: From the app.properties file we are reading the data like on which browser we want to run our scenarios and on which environment. 
  • testdata (folder): It will contain Excel, xml or text files with data.

Folders/Files in Project Root Directory

  • TestNG.xml: TestNG.xml is the file that we have created to run our automation suite. 
  • pom.xml: pom.xml is already created by maven. When you are creating a maven project. In this, we have to add dependency.
  • drivers (folder): We have created one Drivers directory that is not a part of any package. In drivers folder we are storing our driver.exe files
  • logs (folder): To store logs.