Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Playwright Test Framework
env:
TZ: Asia/Kolkata

on:
workflow_dispatch:
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ Automated end-to-end testing framework built with Playwright and Java, tailored
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](https://github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge) for beautifully generating an entire easy-to-understand tutorial for this GitHub Repo.
Thanks to [The Pocket](https://github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge) 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](https://code2tutorial.com/tutorial/81c3753d-35c2-41fd-941c-34a1c851e80c/index.md).
You can read the entire
tutorial [here](https://code2tutorial.com/tutorial/81c3753d-35c2-41fd-941c-34a1c851e80c/index.md).

# TEST ARCHITECTURE

Expand Down Expand Up @@ -53,7 +55,6 @@ You can read the entire tutorial [here](https://code2tutorial.com/tutorial/81c37

<img width="1697" alt="Browser_Creation_Flow" src="https://github.com/user-attachments/assets/34f8530d-33a7-4612-9346-2fc5958f41da" />


# CHROME DEVTOOLS PROTOCOL IMPLEMENTATION EXPLAINED

**1. Initialize the CDP Session**
Expand Down Expand Up @@ -125,6 +126,8 @@ You can read the entire tutorial [here](https://code2tutorial.com/tutorial/81c37
| 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public BrowserContext createSession(Playwright playwright, boolean isHeadless) {
return playwright.chromium().launch(new BrowserType.LaunchOptions()
.setHeadless(isHeadless))
.newContext(new Browser.NewContextOptions()
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT));
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT)
.setTimezoneId(WebPortalConstants.TIME_ZONE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public BrowserContext createSession(Playwright playwright, boolean isHeadless) {
return playwright.firefox().launch(new BrowserType.LaunchOptions()
.setHeadless(isHeadless))
.newContext(new Browser.NewContextOptions()
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT));
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT)
.setTimezoneId(WebPortalConstants.TIME_ZONE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public BrowserContext createSession(Playwright playwright, boolean isHeadless) {
return playwright.chromium().launch(new BrowserType.LaunchOptions()
.setHeadless(isHeadless).setChannel(BrowserName.MS_EDGE.getBrowserType()))
.newContext(new Browser.NewContextOptions()
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT));
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT)
.setTimezoneId(WebPortalConstants.TIME_ZONE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public BrowserContext createSession(Playwright playwright, boolean isHeadless) {
return playwright.webkit().launch(new BrowserType.LaunchOptions()
.setHeadless(isHeadless))
.newContext(new Browser.NewContextOptions()
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT));
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT)
.setTimezoneId(WebPortalConstants.TIME_ZONE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ public final class WebPortalConstants {
// DYNAMIC BROWSER & ENVIRONMENT CHOICE
public static final String RUN_MODE = System.getProperty("runmode");
public static final String BROWSER = System.getProperty("browser");
public static final String TIME_ZONE = "Asia/Kolkata";

public static final int SCREEN_WIDTH = 1920;
public static final int SCREEN_HEIGHT = 1080;

public static final String SCREENSHOT_FILE_LOCATION = "./src/test/resources/screenshots/";
public static final String SCREENSHOT_FILE_LOCATION = "./target/screenshots/";
public static final String IMAGE_FORMAT = ".png";
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void takeScreenshot(ITestResult testResult) {
String directory = testResult.isSuccess() ? "passed_screenshots" : "failed_screenshots";
String timestamp = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date());
String parameter = extractSafeParameter(testResult);
String fileName = formatScreenshotFileName(statusPrefix, testName, parameter, timestamp);
String fileName = formatScreenshotFileName(statusPrefix, testName, parameter, timestamp).replaceAll(":", "_");
String dirPath = Paths.get(WebPortalConstants.SCREENSHOT_FILE_LOCATION + "/pages/", directory).toString();
String filePath = Paths.get(dirPath, fileName).toString();
try {
Expand Down