Go Green One tree
One life
Trees
Loading...

Explain Selenium Automation Framework & Its Components

Author
SPEC INDIA
Posted

August 27, 2024

Updated

September 16th, 2024

Selenium Automation Framework & Its Components

Many times, automation engineers use the company’s existing selenium automation framework or create a custom framework from scratch but feel confused when it comes to explaining the Framework they are using or the Framework they have created.

In this article, we will cover the Selenium Data Driven Framework and its components. Your framework might differ in a few components, but we have tried to cover most generic tools and components used in the industry.

We are taking the example of Selenium Data-Driven Framework created in JAVA language using TestNG testing framework with Maven as dependency manager, Jenkins as a CI/CD, GIT as a version control, Apache POI for managing Data in excel file and using POM design patterns.

It might be possible that you have used different programming languages, e.g., Python, pytest as a framework in software testing, etc. Still, they are just implementation-level differences, and that doesn’t matter when we are explaining the Selenium components and features of the Framework in general.

Selenium testing frameworks are classified into three main types:

  • Data-driven framework
  • Keyword driven framework
  • Hybrid framework

Classified Types of Selenium Framework

This blog will focus more on the data-driven framework in selenium, so stay tuned.

What is the Selenium Framework?

Selenium Framework is a tool that provide automation of web testing. It is developed with JavaScript and the ability to run tests right in the web browser, work with web pages, and have tests repeated – without typing.

What this means is that you will not need to go through the process of manually data-driven testing the software, which is often moving, time-consuming, and redundant. Selenium is a good fit for Agile and DevOps, as these approaches are based on frequent updates and rapid release.

Apparently, due to its effectiveness, Selenium is preferred by most businesses that seek to minimize the duration of their testing.

After the overview of the data driven framework in selenium let’s understand its structure and components of the Framework in detail so that a user can understand how the framework is organized and how to place files in different folders or packages.

Base: In /main/java, we have created packages for page objects & base class, utilities and extent listeners.

Extent Listener: We are using Extent Report for reporting the test suite execution results. The extent listener package holds classes for extent manager class and the listener class which extends methods of ITestListener interface of TestNG.

Page Objects: We are using POM design pattern to store page wise elements and functions that are commonly used in the automation scripts. Also, this package holds the base class which is used to create the instance of driver which then can be used to execute scripts on different browsers & to perform user actions like opening application, clicking on login button etc.

Utilities: this package has several classes for managing data from excel file, driver manager class for initiating different browsers and few ancillary classes for holding the constants like URL of application etc.

Tests: In /test/java, we have created packages for creating selenium test automation test of different modules. For e.g. Login module. We can also create packages here for adding end-to-end tests of the application or to create regression suite.

  • Resources: In /test/java, there is one more folder named “resources,” which is used for:
  • Executables: for holding driver executables files
  • Extent Config: holding XML file for extent report configuration
  • Grid: for holding selenium server jars and for batch scripts to start hub and node while running parallel tests using selenium grid.
  • Logs: This holds log4j2 log files to maintain the test execution logs
  • Properties: For property files like config property, which hold general properties like browsers, etc., and for storing log4J2 properties
  • Runner: Here, we are placing the TestNG XML file for running different test suites & for parallel or sequential execution of tests
  • Test Data: For storing test data, use Excel files from which data can be read during the execution.
  • Reports: All the extent reports generated after the execution along with screenshots of failures will be stored in the Reports folder.
  • Pom.xml: We are using Maven as a dependency manager, and all the dependencies will be maintained in the pom.xml file.

Interesting to Read: Selenium Alternatives for Optimal Testing Output

Moving further let’s discuss the features of selenium data driven framework.

Features of Data-Driven Framework in Selenium

  • Modular Structure: The Selenium Framework is based on OOPS concepts and has a modular structure. We are maintaining objects and test cases in separate files and also there are separate classes for managing drivers, utilities and configurations. Since we are using POM (Page Object Model), it allows us to reuse the object and methods as and when required.
  • Multi-Browser & Multi-OS Support: It is possible to run tests on browsers like Chrome, Firefox, Microsoft Edge & Safari. Also, it allows you to run tests on different OS e.g Windows, Mac or Linux.
  • Parallel Execution: Using Selenium Grid, it is possible to run tests in distribution mode and can execute tests on multiple browsers in parallel.
  • CI/CD: we have created a scheduled job in Jenkins that will execute the regression suite and will generate the execution reports.
  • Retry On Failures: The Framework also has retry mechanism where after executing the suite, it will check for failed test cases and will re-execute them again to ensure that there are no accidental failures while executing multiple tests in a suite. We can define the number of times framework will execute the failed test cases.
  • Screenshots: The Framework is enabled with capturing the screenshot in case test step fails during the test execution and it will be visible in the extent report along with the exception details
  • Reports: After each execution, a nice HTML extent report will be generated which will show summary of execution along with passed and failed test cases with all the steps that are executed. In case of test failure, it will capture the steps that failed and will also log the exception thrown at the time of failure.
  • Logs: Logs are being generated in the Framework so that it can help us in debugging if there are any execution errors and need to make fixes in the scripts.
  • Scalable & Extendable: The Framework is completely scalable, and it is possible to execute the automation suite on containers. We can also extend the Framework to add further features. For e.g. we are capturing screenshots, but we can also add custom utility method to generate video of execution and store it at preferred location.
  • Plug n Play: The Framework is easy to configure and maintain. Users can start creating scripts within minutes after setting up the Framework & can start executing it. This saves effort in creating a new framework and helps to boost productivity.

Conclusion

In this way, you can cover all the major components of the framework along with tools and technologies, and you can confidently explain its features and advantages. Whether you are a novice or an experienced automation engineer, it will be easy for anyone who wants to understand it and use it in the project.

spec author logo
Author
SPEC INDIA

SPEC INDIA, as your single stop IT partner has been successfully implementing a bouquet of diverse solutions and services all over the globe, proving its mettle as an ISO 9001:2015 certified IT solutions organization. With efficient project management practices, international standards to comply, flexible engagement models and superior infrastructure, SPEC INDIA is a customer’s delight. Our skilled technical resources are apt at putting thoughts in a perspective by offering value-added reads for all.

Let’s get in touch!