Selenium Test Automation Framework
Technical Feed
Hima Samraj November 10, 2017

Selenium community provides a suite of tools for web application testing, out of which Selenium WebDriver is an advanced tool having native support with multiple browsers. This means that it can communicate directly with browsers and controls operations performed on them, thus supporting automation of web applications.

The test automation framework developed at ThinkPalm is a hybrid framework implemented using Selenium WebDriver and TestNG. It combines the features of Keyword driven, Modular and Datadriven frameworks.

Selenium Test Automation Framework Architecture

There are different components available in this framework, major ones being:

1) TextNG Xml

This is the triggering point of the framework. It includes a list of test suites to be executed for current run. TestNG XML enables batch execution of testscripts.

2) TestScripts

Testscript package includes a set of java classes that implements the generic features of the framework. Various class files in the testscript package are:

  • CommonFunction.java
  • DriverScript.java
  • Keywords.java
  • Module 1.java .  .  .  Module N.java

CommonFunction.java is the generic library containing public and static methods that can be used across any project. This includes implementation of all application independent methods used in the framework and various operations performed on web elements. DriverScript manages and controls complete execution of the framework by loading all utilities and configuration files. It monitors the execution of testscripts. Keywords.java class contains the definition of all keywords used across the framework. These keywords are implemented at operational level. Module.java – The framework is modular in nature and contains testscripts that are distributed across different business modules, each having a separate java class. These classes are named based on the module name and implement methods specific to a particular module.

3) Config package

Config package contains all configuration settings and log files including:

  • Application.log
  • Config.properties
  •  Selenium.log
  •  Module 1.Objects.properties
  •  Module 1.controller.xlsx

The framework uses Log4j  Logging Services to generate execution logs. Module.Objects.properties is the repository for all object definitions used in the test scripts. We use properties file to store and retrieve the UI elements of an application or a website. It contains id of the elements, name, xpath, CSS selector etc. Module.controller.xlsx contains multiple excel sheets with each sheet having sequential flow of activities for a specific business scenario. There is a single “suite” sheet which lists all test scenarios specific to the module with Run Mode value “Y” or “N”.

4) DataTable

Xlfile_Reader is a generic library that implements excel file manipulation methods. This framework supports only excel files as input data feed. It uses Apache POI API to read data from excel files and write results in excel files.

5) Reports

ReportUtil.java file implements the customized test reporting feature of the framework and generates customized test reports at each step of execution.

6) Util

Util package includes various configuration files which implement features like Database connectivity, Email configuration setting and more. It contains the various reusable classes and methods for overall run of the test suite. DbManager class covers DB connectivity settings & execute Query, MonitoringMail class implements email notification feature, TestConfig  class includes configuration details for mail/db servers, TestUtil  class enables screen capture, Zip Reports and get current date time.

Test Execution Flow

The framework is driven through TestNG XML. While running TestNG XML, it executes the test suite which is actually a bunch of test scenarios. As each test scenario runs, it calls the excel library which will connect to the appropriate test data excel file and get data which is required for the current test. Once test data is read, each test connects to business and generic libraries to run the actual test. With the test execution in progress, we have log4j to write the result in console/log files.