diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java index a78af52a..3b8ae688 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java @@ -1358,9 +1358,12 @@ public JSHandle waitForFunction(String pageFunction, Object arg, WaitForFunction @Override public void waitForLoadState(LoadState state, WaitForLoadStateOptions options) { - withWaitLogging("Page.waitForLoadState", logger -> { - mainFrame.waitForLoadStateImpl(state, convertType(options, Frame.WaitForLoadStateOptions.class), logger); - return null; + final LoadState loadState = state == null ? LoadState.LOAD : state; + withTitle("Wait for load state \"" + loadState.toString().toLowerCase() + "\"", () -> { + withWaitLogging("Page.waitForLoadState", logger -> { + mainFrame.waitForLoadStateImpl(loadState, convertType(options, Frame.WaitForLoadStateOptions.class), logger); + return null; + }); }); } diff --git a/playwright/src/test/java/com/microsoft/playwright/TestTracing.java b/playwright/src/test/java/com/microsoft/playwright/TestTracing.java index be9a6fe1..69008ab9 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestTracing.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestTracing.java @@ -359,4 +359,24 @@ public void shouldNotRecordNetworkActions(@TempDir Path tempDir) throws Exceptio }); }); } + + @Test + public void shouldShowWaitForLoadState(@TempDir Path tempDir) throws Exception { + // https://github.com/microsoft/playwright/issues/37297 + + context.tracing().start(new Tracing.StartOptions()); + + page.navigate(server.EMPTY_PAGE); + page.waitForLoadState(); + + Path traceFile1 = tempDir.resolve("trace1.zip"); + context.tracing().stop(new Tracing.StopOptions().setPath(traceFile1)); + + TraceViewerPage.showTraceViewer(this.browserType, traceFile1, traceViewer -> { + assertThat(traceViewer.actionTitles()).hasText(new Pattern[] { + Pattern.compile("Navigate to \"/empty.html\""), + Pattern.compile("Wait for load state \"load\""), + }); + }); + } }