From 61c2eb41e9995f1aea4e0861875cbf397b061003 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Thu, 4 Sep 2025 16:57:27 +0200 Subject: [PATCH 1/2] fix(trace): waitForLoadState title --- .../microsoft/playwright/impl/PageImpl.java | 11 ++++++---- .../com/microsoft/playwright/TestTracing.java | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) 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 a78af52aa..4a7a5c2fe 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java @@ -1357,10 +1357,13 @@ 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; + public void waitForLoadState(LoadState _state, WaitForLoadStateOptions options) { + final LoadState state = _state == null ? LoadState.LOAD : _state; + withTitle("Wait for load state \"" + state.toString().toLowerCase() + "\"", () -> { + withWaitLogging("Page.waitForLoadState", logger -> { + mainFrame.waitForLoadStateImpl(state, 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 be9a6fe15..69008ab9e 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\""), + }); + }); + } } From 4743a3f42861469a34278db75c195c820ec9fe2c Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Mon, 8 Sep 2025 09:04:11 +0200 Subject: [PATCH 2/2] rename --- .../main/java/com/microsoft/playwright/impl/PageImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 4a7a5c2fe..3b8ae6883 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java @@ -1357,11 +1357,11 @@ public JSHandle waitForFunction(String pageFunction, Object arg, WaitForFunction } @Override - public void waitForLoadState(LoadState _state, WaitForLoadStateOptions options) { - final LoadState state = _state == null ? LoadState.LOAD : _state; - withTitle("Wait for load state \"" + state.toString().toLowerCase() + "\"", () -> { + public void waitForLoadState(LoadState state, WaitForLoadStateOptions options) { + final LoadState loadState = state == null ? LoadState.LOAD : state; + withTitle("Wait for load state \"" + loadState.toString().toLowerCase() + "\"", () -> { withWaitLogging("Page.waitForLoadState", logger -> { - mainFrame.waitForLoadStateImpl(state, convertType(options, Frame.WaitForLoadStateOptions.class), logger); + mainFrame.waitForLoadStateImpl(loadState, convertType(options, Frame.WaitForLoadStateOptions.class), logger); return null; }); });