|
1 | 1 | package com.tmail.base;
|
2 | 2 |
|
3 | 3 | import java.io.IOException;
|
| 4 | +import java.nio.file.Paths; |
4 | 5 | import java.util.Arrays;
|
5 | 6 | import java.util.Properties;
|
6 | 7 | import java.util.stream.Stream;
|
|
15 | 16 | import org.junit.jupiter.params.provider.MethodSource;
|
16 | 17 |
|
17 | 18 | import com.microsoft.playwright.Browser;
|
| 19 | +import com.microsoft.playwright.Browser.NewContextOptions; |
18 | 20 | import com.microsoft.playwright.BrowserContext;
|
19 | 21 | import com.microsoft.playwright.BrowserType;
|
20 | 22 | import com.microsoft.playwright.Page;
|
21 | 23 | import com.microsoft.playwright.Playwright;
|
| 24 | +import com.microsoft.playwright.Tracing; |
22 | 25 |
|
23 | 26 | @ExtendWith(CustomParameterResolver.class)
|
24 | 27 | @TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@@ -55,13 +58,21 @@ public void setUp(SupportedPlatform supportedPlatform) {
|
55 | 58 | case FIREFOX -> playwright.firefox().launch(new BrowserType.LaunchOptions().setHeadless(runHeadlessTest));
|
56 | 59 | default -> throw new UnsupportedPlatformException();
|
57 | 60 | };
|
58 |
| - browserContext = browser.newContext( |
59 |
| - new Browser.NewContextOptions().setViewportSize(1920, 1080)); |
| 61 | + |
| 62 | + NewContextOptions contextOptions = new Browser.NewContextOptions() |
| 63 | + .setViewportSize(1920, 1080); |
| 64 | + browserContext = browser.newContext(contextOptions); |
| 65 | + browserContext.tracing().start(new Tracing.StartOptions() |
| 66 | + .setScreenshots(true) |
| 67 | + .setSnapshots(true)); |
| 68 | + |
60 | 69 | page = browserContext.newPage();
|
61 | 70 | }
|
62 | 71 |
|
63 | 72 | @AfterEach
|
64 | 73 | public void tearDown() {
|
| 74 | + browserContext.tracing().stop(new Tracing.StopOptions() |
| 75 | + .setPath(Paths.get("trace.zip"))); |
65 | 76 | page.close();
|
66 | 77 | browserContext.close();
|
67 | 78 | browser.close();
|
|
0 commit comments