Exploring Prism Web Automation Testing Framework On Java-Selenium

01 / Apr / 2024 by Mohammad Farhan 0 comments

Introduction

PRISM stands out as a comprehensive solution worth exploring in the vast landscape of testing frameworks for web, mobile, and APIs.This blog is focused on PRISM’s web testing framework, meticulously crafted on the robust foundation of the Selenium library, TestNG framework, with Java as the binding language. Leveraging Maven as the dependency management tool for the project, PRISM offers a streamlined and efficient approach to web testing, ensuring reliability and scalability in every test scenario. Let’s dig deep into how PRISM empowers test developers to achieve outstanding testing prowess.

Structure of framework

To understand the framework and to use it we need to understand the above structure or you can add things while using the framework according to your project requirements.

Base Package

The Base Package contains three files:

  • BaseLib
  • BrowserFactory
  • ExtentManger

BaseLib: It is a class that will extend to child classes that are test script classes. It contains a method that has annotations of the testNG framework that are Parameter BeforeSuite, BeforeTest, BeforeClass, BeforeMethod, AfterMethod, AfterClass, AfterTest, and AfterSuite.

Note:

  1.  Two more notations will use Test and DataProvider in our test class. We are using ItestListener.
  2. For a better understanding of the order of execution of notations and ListenersClass in the Listene Package (ItestListner), it is recommended to go through the TestNG framework annotations. In the PRISM framework method execute according to the priority or order of notation in the TestNG framework.

BrowserFactory Class: This class consists of a method that initiates a driver according to requirements, like a driver for Chrome, Firefox, remote drivers, or a driver that has the capability for cloud-like Browser stack, Lambda, etc. It also has a function to quiet the browser. In our test script, we mostly call this method in our parent class i.e., the BaseLib.java class. We initiate drivers at any level like on test level, class level, and method level. It is according to our needs or depending on parallel execution of test cases based on method, class, and test-level execution. Focus on the segregation or independence of the test script so it does not hamper test execution.

ExtentManager Class: This class consists of methods that initialize properties of ExtentReports, and ExtentHtmlReporter objects and return to where they are class for initialization and use in whole test execution; it mostly initializes at BeforeSuite and is used in the whole process like logging test status like failures, passes, skips, etc.

How it goes

We write our test script in the Test package by extending BaseLib and using the reusable method of our Business logic i.e. written in pageObjects package. For our naming convenience, we end the Business logic class with a page in their name like: FiltersOnSummaryViewPageForBookingPage.java

These logic are scenarios that we test, and we assert these execution results in our Test Script Class that are end by Test in their name like FiltersOnSummaryViewPageForBookingTest.java. You can see both examples as shown below images

In the above case, we Talk about reusable methods of the Business logic class, on the execution of this method, we get the result that is tested or asserted at a place where this method has been called by a test case that is in the Test script class.

To understand this, we need to know how these methods are implemented and how their results are asserted by test script.

For writing test logic like for clicking, scrolling, typing, drag and drop, etc, we already have reusable code or functions that had been built using the selenium function and have a logger in them so we can debug. In PRISM we have named that as a SeleniumHelper class in the seleniumUtils package. If we don’t have any particular function for certain operations, we make a reusable function in CommonUtility class this class we will build if we need it in the seleniumUtils package.

When we use any function of the SeleniumHelper class, it will log for that operation. If we use the click function, it will automatically log the logger in the console, RP, or in the file as you mention in the logback.xml file of the resources folder in this folder, you also find the reportportal.properties file. In the reportportal.properties file, we will provide the reporting portal link UUID for the user who can log on to that reporting portal. Name of  Project of reporting portal on which your project log will be generated. Lunch name by this name should be seen on the reporting portal.

Utilib Package

This package is like a Swiss knife; this contains almost all the classes that are needed for automation, like the class for mail triggering, file readers like CSV reader, Excel reader, Google sheet reader, property file reader, random generators for Numbers, Alphabets, Aplhnumeric etc, Screenshot taker, file handler, JiraOperation for bug log, HealthCheckUtils, Zip Directory, Data provider.

DataProviderSource file is used in Test Script using TestNG annotation, i.e., dataProvider.

In this method, we define how we will get data in the above image; we can see that we are getting it from an Excel reader. This data is returned in the form of an Object array, and at the place where we had called it explicitly may convert to any 2d form of data structure. As preferred, we can convert it to HashTable.

TestNG.xml is used to run this Test Classes

  1. First Reference
  2. Second Reference
  3. Third Reference with Parallel references

Pom.xml is the heart of the maven project; it manages the dependencies that are needed to build and run the Project. If the project loses its Pom, then it cannot be run unless dependencies or external libraries are already present in your project.in PRISM POM, we add maven-surefire-plugin that triggers the TestNG, and also we add System property for ReportPortal as shown in the below Image

Advantage

Comprehensive Automation Solutions

PRISM offers a distinct advantage by providing all the essential libraries and code required for automation, obviating the need for test developers to construct entire setups from scratch. This not only saves invaluable time but also enhances productivity by allowing developers to focus on refining test cases and enhancing test coverage.

Harnessing Market-Leading Technologies

One of the key strengths of PRISM lies in its foundation on Selenium and Java, two pillars of automation that enjoy a significant market share. Selenium, renowned for its robustness and versatility in web automation, boasts a staggering 50.79% customer base from the United States, reaffirming its widespread adoption and reliability. Coupled with Java, a language embraced by over 56% of production applications, PRISM leverages these technologies’ collective strength to deliver seamless automation solutions that cater to diverse requirements and scenarios.

Simplified Project Management with Maven

Furthermore, PRISM integrates seamlessly with Maven, serving as a dependency management tool that simplifies project configuration and ensures smooth execution. Maven’s popularity is evident from its customer base, with 50.48% originating from the United States, underscoring its global appeal and effectiveness in managing project dependencies. With India and the United Kingdom following closely behind, Maven emerges as a cornerstone of automation projects worldwide, facilitating efficient collaboration and project scalability.

Conclusion

Adopting PRISM for automation heralds a new era of efficiency and effectiveness in software testing. By harnessing the strengths of Selenium, Java, and Maven, PRISM empowers test developers to overcome challenges and accelerate the pace of development. As the automation landscape evolves, embracing Prism ensures a competitive edge and enables organizations to stay ahead in a rapidly changing environment.

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *