11package com .serenitydojo .playwright .toolshop .contact ;
22
3+ import com .microsoft .playwright .BrowserContext ;
34import com .microsoft .playwright .Page ;
5+ import com .microsoft .playwright .Tracing ;
46import com .microsoft .playwright .junit .UsePlaywright ;
57import com .microsoft .playwright .options .AriaRole ;
68import com .serenitydojo .playwright .HeadlessChromeOptions ;
1012import io .qameta .allure .Feature ;
1113import io .qameta .allure .Story ;
1214import 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 .*;
1616import org .junit .jupiter .params .ParameterizedTest ;
1717import 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