11package com .serenitydojo .playwright .toolshop .catalog ;
22
3+ import com .microsoft .playwright .Browser ;
4+ import com .microsoft .playwright .BrowserContext ;
35import com .microsoft .playwright .Page ;
6+ import com .microsoft .playwright .Tracing ;
47import com .microsoft .playwright .junit .UsePlaywright ;
58import com .serenitydojo .playwright .HeadlessChromeOptions ;
69import com .serenitydojo .playwright .toolshop .catalog .pageobjects .*;
710import com .serenitydojo .playwright .toolshop .fixtures .PlaywrightTestCase ;
811import org .assertj .core .api .Assertions ;
12+ import org .junit .jupiter .api .AfterEach ;
913import org .junit .jupiter .api .BeforeEach ;
1014import org .junit .jupiter .api .Test ;
1115import org .junit .jupiter .api .parallel .Execution ;
1216import org .junit .jupiter .api .parallel .ExecutionMode ;
1317
18+ import java .nio .file .Paths ;
1419import java .util .List ;
1520
1621@ UsePlaywright (HeadlessChromeOptions .class )
@@ -36,6 +41,24 @@ void setUp(Page page) {
3641 checkoutCart = new CheckoutCart (page );
3742 }
3843
44+ @ BeforeEach
45+ void setupTrace (BrowserContext context ) {
46+ context .tracing ().start (
47+ new Tracing .StartOptions ()
48+ .setScreenshots (true )
49+ .setSnapshots (true )
50+ .setSources (true )
51+ );
52+ }
53+
54+ @ AfterEach
55+ void recordTrace (BrowserContext context ) {
56+ context .tracing ().stop (
57+ new Tracing .StopOptions ()
58+ .setPath (Paths .get ("trace.zip" ))
59+ );
60+ }
61+
3962 @ Test
4063 void whenCheckingOutASingleItem () {
4164 searchComponent .searchBy ("pliers" );
0 commit comments