Skip to content

Commit 0cd3018

Browse files
committed
Added traces for contact form test
1 parent acd0f51 commit 0cd3018

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

.github/workflows/playwright-tests.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,12 @@ jobs:
5050
# Step 4: Run Maven to execute Playwright tests
5151
- name: Run Playwright Tests
5252
run: mvn verify
53+
54+
55+
# Step 7: Archive ZIP files in the root directory
56+
- name: Archive ZIP files
57+
if: always() # Ensure this step runs even if previous steps fail
58+
uses: actions/upload-artifact@v3
59+
with:
60+
name: zip-archives
61+
path: '*.zip'

src/test/java/com/serenitydojo/playwright/toolshop/contact/ContactFormTest.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.serenitydojo.playwright.toolshop.contact;
22

3+
import com.microsoft.playwright.BrowserContext;
34
import com.microsoft.playwright.Page;
5+
import com.microsoft.playwright.Tracing;
46
import com.microsoft.playwright.junit.UsePlaywright;
57
import com.microsoft.playwright.options.AriaRole;
68
import com.serenitydojo.playwright.HeadlessChromeOptions;
@@ -10,9 +12,7 @@
1012
import io.qameta.allure.Feature;
1113
import io.qameta.allure.Story;
1214
import org.assertj.core.api.Assertions;
13-
import org.junit.jupiter.api.BeforeEach;
14-
import org.junit.jupiter.api.DisplayName;
15-
import org.junit.jupiter.api.Test;
15+
import org.junit.jupiter.api.*;
1616
import org.junit.jupiter.params.ParameterizedTest;
1717
import org.junit.jupiter.params.provider.ValueSource;
1818

@@ -37,6 +37,26 @@ void openContactPage(Page page) {
3737
navigate.toTheContactPage();
3838
}
3939

40+
41+
@BeforeEach
42+
void setupTrace(BrowserContext context) {
43+
context.tracing().start(
44+
new Tracing.StartOptions()
45+
.setScreenshots(true)
46+
.setSnapshots(true)
47+
.setSources(true)
48+
);
49+
}
50+
51+
@AfterEach
52+
void recordTrace(TestInfo testInfo, BrowserContext context) {
53+
String traceName = testInfo.getDisplayName().replace(" ","-").toLowerCase();
54+
context.tracing().stop(
55+
new Tracing.StopOptions()
56+
.setPath(Paths.get("trace-" + traceName + ".zip"))
57+
);
58+
}
59+
4060
@Story("Submitting a request")
4161
@DisplayName("Customers can use the contact form to contact us")
4262
@Test

0 commit comments

Comments
 (0)