

ABOUT
Automated end-to-end testing framework built with Playwright and Java, tailored for any website. Designed
for scalability and maintainability, this framework covers critical test scenarios with robust assertions and clean,
modular code. Perfect for those looking to speed up their test automation journey or enhance their Playwright skills!
Thanks to The Pocket for beautifully generating
an entire easy-to-understand tutorial for this GitHub Repo.
Massive respect for creating such a wonderful tool. Simply Brilliant! ❤️
You can read the entire
tutorial here.
TEST ARCHITECTURE
A High Level Diagram for the framework is below.
High Level Diagram by Archify
STEPS FOR THE TEST EXECUTION IN LOCAL
git clone https://github.com/iamcharankumar/playwright_test_framework.git
cd playwright_test_framework
git pull
mvn clean test -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3
SUPPORTED BROWSERS
- Chrome
-Dbrowser=chrome (default value is chrome)
- Firefox
-Drunmode=firefox
- Microsoft Edge
-Drunmode=msedge
SUPPORTED RUN MODES
- local
-Drunmode=local (default value is local)
- headless
-Drunmode=headless
BROWSER CREATION FLOW
- A client requests a browser page from
BrowserManager.getBrowserPage()
BrowserManager reads system properties to determine browser type and headless mode
BrowserFactory creates the appropriate browser implementation based on the browser name
- The browser implementation creates a session with the required configuration
BrowserManager creates and returns a new page from the browser context
- When finished, the client calls
destroyBrowserPage() to clean up resources.
1. Initialize the CDP Session
What Happens?
- You (the test) ask CdpUtils to start monitoring.
- CdpUtils tells CDPSessionHandlerImpl to set things up.
- Playwright provides the tools (CDPSession).

2. Listen for Network Errors
What Happens?
- You ask to log errors (e.g., HTTP 404/500).
- The CDPSessionHandlerImpl sets up a listener in the browser.

3. Browser Fires an Event
What Happens?
- The browser detects a failed request → notifies CDPSessionHandlerImpl.
- The error details are passed back to your test (e.g., to log or retry).

REPORTPORTAL INTEGRATION
- To integrate your test reports with the open source tool - Reportportal, please
refer to
this section
in my java-selenium framework repo for installation as well as the integration.
INTEGRATE DISCORD MESSAGE SERVICE
- To send test reports from Reportportal to any Discord Message Channel, please refer to
this section
and all the classes in
this package
of the same java-selenium framework repo.
- In this framework, Discord has been integrated via Github actions. Refer final result in the image below.

- The code coverage is leveraged via Github Actions integrating codecov tool.
- The latest code coverage for this project is
available here.
- The code coverage grid:

- Below is the maven commands combo that will help you to cover all the supported browsers and runmodes.
- These maven commands (no testng.xml required) are executed with the respective groups and thread counts.
The listeners [screenshot, retry, etc] are configured in “pom.xml” under “< property >” tag.
BROWSERS & RUN MODES
| Sl.No |
Browser Name |
Run Mode |
mvn command |
| 1 |
Chrome |
Local |
mvn clean test -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3 |
| 2 |
Chrome |
Headless |
mvn clean test -Drunmode=headless -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3 |
| 3 |
Firefox |
Local |
mvn clean test -Dbrowser=firefox -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3 |
| 4 |
Firefox |
Headless |
mvn clean test -Drunmode=headless -Dbrowser=firefox -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3 |
| 5 |
Edge |
Local |
mvn clean test -Dbrowser=msedge -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3 |
| 6 |
Edge |
Headless |
mvn clean test -Drunmode=headless -Dbrowser=msedge -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3 |
| 7 |
WebKit |
Local |
mvn clean test -Dbrowser=webkit -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3 |
| 8 |
WebKit |
Headless |
mvn clean test -Drunmode=headless -Dbrowser=webkit -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3 |
NOTE: These above commands (no testng.xml required) will run the tests in parallel with the specified thread count
and with the respective groups and thread counts.
The screenshot listeners are configured in “pom.xml” under “< property >” tag.
DECLUTTERING MAVEN OUTPUT
- Maven usually floods the console with logs during test execution, making it hard to spot what’s important.
A clean, minimal, Node.js-style output for a Java project felt impossible—until I
found this maven dependency.
- Its purpose is simple: “What happened to my test cases?” That’s exactly what it shows—straight to the point, no
clutter.
- By following this post
by Fabricio,
I was able to configure it easily and get the clean output shown below.
- The output works locally and in GitHub Actions as well.
- Huge respect and thanks to the author for this
brilliant work!
❤️
Before the Decluttering
After the Decluttering
Star History

评论