File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
src/test/java/org/javadominicano Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -22,16 +22,24 @@ public static void beforeAll() {
2222 playwright = Playwright .create ();
2323 BrowserType browserType = playwright .chromium ();
2424
25- BrowserType .LaunchOptions launchOptions = new BrowserType .LaunchOptions ().setHeadless (true );
26- launchOptions .headless = false ;
25+ boolean headless = Boolean .parseBoolean (
26+ System .getenv ().getOrDefault ("HEADLESS" , "true" )
27+ );
28+
29+ BrowserType .LaunchOptions launchOptions = new BrowserType .LaunchOptions ()
30+ .setHeadless (headless );
2731
2832 browser = browserType .launch (launchOptions );
2933 }
3034
3135 @ AfterAll
3236 public static void afterAll () {
33- browser .close ();
34- playwright .close ();
37+ if (browser != null ) {
38+ browser .close ();
39+ }
40+ if (playwright != null ) {
41+ playwright .close ();
42+ }
3543 }
3644
3745 @ BeforeEach
@@ -50,8 +58,8 @@ void beforeEach() {
5058
5159 @ AfterEach
5260 void afterEach () {
53- page .close ();
54- browserContext .close ();
61+ if ( page != null ) page .close ();
62+ if ( browserContext != null ) browserContext .close ();
5563 }
5664
5765}
You can’t perform that action at this time.
0 commit comments