Skip to content

Commit 7af52d8

Browse files
Merge pull request #47 from iamcharankumar/fb_time_zone
IST Time Zone set for Github CI/CD and browsers
2 parents 4b213a1 + 4feb790 commit 7af52d8

File tree

8 files changed

+19
-9
lines changed

8 files changed

+19
-9
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: Playwright Test Framework
2+
env:
3+
TZ: Asia/Kolkata
24

35
on:
46
workflow_dispatch:

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ Automated end-to-end testing framework built with Playwright and Java, tailored
1515
for scalability and maintainability, this framework covers critical test scenarios with robust assertions and clean,
1616
modular code. Perfect for those looking to speed up their test automation journey or enhance their Playwright skills!
1717

18-
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.
18+
Thanks to [The Pocket](https://github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge) for beautifully generating
19+
an entire easy-to-understand tutorial for this GitHub Repo.
1920
Massive respect for creating such a wonderful tool. Simply Brilliant! ❤️
2021

21-
You can read the entire tutorial [here](https://code2tutorial.com/tutorial/81c3753d-35c2-41fd-941c-34a1c851e80c/index.md).
22+
You can read the entire
23+
tutorial [here](https://code2tutorial.com/tutorial/81c3753d-35c2-41fd-941c-34a1c851e80c/index.md).
2224

2325
# TEST ARCHITECTURE
2426

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

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

56-
5758
# CHROME DEVTOOLS PROTOCOL IMPLEMENTATION EXPLAINED
5859

5960
**1. Initialize the CDP Session**
@@ -125,6 +126,8 @@ You can read the entire tutorial [here](https://code2tutorial.com/tutorial/81c37
125126
| 4 | Firefox | Headless | `mvn clean test -Drunmode=headless -Dbrowser=firefox -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3` |
126127
| 5 | Edge | Local | `mvn clean test -Dbrowser=msedge -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3` |
127128
| 6 | Edge | Headless | `mvn clean test -Drunmode=headless -Dbrowser=msedge -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3` |
129+
| 7 | WebKit | Local | `mvn clean test -Dbrowser=webkit -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3` |
130+
| 8 | WebKit | Headless | `mvn clean test -Drunmode=headless -Dbrowser=webkit -Dgroups=SWAG_LABS_SMOKE,SWAG_LABS_REGRESSION,SWAG_LABS_E2E -Dthreads=3 -Ddataproviderthreadcount=3` |
128131

129132
**NOTE**: These above commands (no testng.xml required) will run the tests in parallel with the specified thread count
130133
and with the respective groups and thread counts.

src/main/java/io/swaglabs/portal/qa/browsermanager/ChromeBrowser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public BrowserContext createSession(Playwright playwright, boolean isHeadless) {
1313
return playwright.chromium().launch(new BrowserType.LaunchOptions()
1414
.setHeadless(isHeadless))
1515
.newContext(new Browser.NewContextOptions()
16-
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT));
16+
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT)
17+
.setTimezoneId(WebPortalConstants.TIME_ZONE));
1718
}
1819
}

src/main/java/io/swaglabs/portal/qa/browsermanager/FirefoxBrowser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public BrowserContext createSession(Playwright playwright, boolean isHeadless) {
1212
return playwright.firefox().launch(new BrowserType.LaunchOptions()
1313
.setHeadless(isHeadless))
1414
.newContext(new Browser.NewContextOptions()
15-
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT));
15+
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT)
16+
.setTimezoneId(WebPortalConstants.TIME_ZONE));
1617
}
1718
}

src/main/java/io/swaglabs/portal/qa/browsermanager/MsEdgeBrowser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public BrowserContext createSession(Playwright playwright, boolean isHeadless) {
1212
return playwright.chromium().launch(new BrowserType.LaunchOptions()
1313
.setHeadless(isHeadless).setChannel(BrowserName.MS_EDGE.getBrowserType()))
1414
.newContext(new Browser.NewContextOptions()
15-
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT));
15+
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT)
16+
.setTimezoneId(WebPortalConstants.TIME_ZONE));
1617
}
1718
}

src/main/java/io/swaglabs/portal/qa/browsermanager/WebkitBrowser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public BrowserContext createSession(Playwright playwright, boolean isHeadless) {
1212
return playwright.webkit().launch(new BrowserType.LaunchOptions()
1313
.setHeadless(isHeadless))
1414
.newContext(new Browser.NewContextOptions()
15-
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT));
15+
.setViewportSize(WebPortalConstants.SCREEN_WIDTH, WebPortalConstants.SCREEN_HEIGHT)
16+
.setTimezoneId(WebPortalConstants.TIME_ZONE));
1617
}
1718
}

src/main/java/io/swaglabs/portal/qa/constants/WebPortalConstants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ public final class WebPortalConstants {
1616
// DYNAMIC BROWSER & ENVIRONMENT CHOICE
1717
public static final String RUN_MODE = System.getProperty("runmode");
1818
public static final String BROWSER = System.getProperty("browser");
19+
public static final String TIME_ZONE = "Asia/Kolkata";
1920

2021
public static final int SCREEN_WIDTH = 1920;
2122
public static final int SCREEN_HEIGHT = 1080;
2223

23-
public static final String SCREENSHOT_FILE_LOCATION = "./src/test/resources/screenshots/";
24+
public static final String SCREENSHOT_FILE_LOCATION = "./target/screenshots/";
2425
public static final String IMAGE_FORMAT = ".png";
2526
}

src/test/java/io/swaglabs/portal/qa/listeners/WebTestListeners.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private void takeScreenshot(ITestResult testResult) {
6868
String directory = testResult.isSuccess() ? "passed_screenshots" : "failed_screenshots";
6969
String timestamp = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date());
7070
String parameter = extractSafeParameter(testResult);
71-
String fileName = formatScreenshotFileName(statusPrefix, testName, parameter, timestamp);
71+
String fileName = formatScreenshotFileName(statusPrefix, testName, parameter, timestamp).replaceAll(":", "_");
7272
String dirPath = Paths.get(WebPortalConstants.SCREENSHOT_FILE_LOCATION + "/pages/", directory).toString();
7373
String filePath = Paths.get(dirPath, fileName).toString();
7474
try {

0 commit comments

Comments
 (0)