Skip to content

Commit eb1fea9

Browse files
authored
fix(trace): waitForLoadState title (#1840)
1 parent dd99ce8 commit eb1fea9

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,9 +1358,12 @@ public JSHandle waitForFunction(String pageFunction, Object arg, WaitForFunction
13581358

13591359
@Override
13601360
public void waitForLoadState(LoadState state, WaitForLoadStateOptions options) {
1361-
withWaitLogging("Page.waitForLoadState", logger -> {
1362-
mainFrame.waitForLoadStateImpl(state, convertType(options, Frame.WaitForLoadStateOptions.class), logger);
1363-
return null;
1361+
final LoadState loadState = state == null ? LoadState.LOAD : state;
1362+
withTitle("Wait for load state \"" + loadState.toString().toLowerCase() + "\"", () -> {
1363+
withWaitLogging("Page.waitForLoadState", logger -> {
1364+
mainFrame.waitForLoadStateImpl(loadState, convertType(options, Frame.WaitForLoadStateOptions.class), logger);
1365+
return null;
1366+
});
13641367
});
13651368
}
13661369

playwright/src/test/java/com/microsoft/playwright/TestTracing.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,24 @@ public void shouldNotRecordNetworkActions(@TempDir Path tempDir) throws Exceptio
359359
});
360360
});
361361
}
362+
363+
@Test
364+
public void shouldShowWaitForLoadState(@TempDir Path tempDir) throws Exception {
365+
// https://github.com/microsoft/playwright/issues/37297
366+
367+
context.tracing().start(new Tracing.StartOptions());
368+
369+
page.navigate(server.EMPTY_PAGE);
370+
page.waitForLoadState();
371+
372+
Path traceFile1 = tempDir.resolve("trace1.zip");
373+
context.tracing().stop(new Tracing.StopOptions().setPath(traceFile1));
374+
375+
TraceViewerPage.showTraceViewer(this.browserType, traceFile1, traceViewer -> {
376+
assertThat(traceViewer.actionTitles()).hasText(new Pattern[] {
377+
Pattern.compile("Navigate to \"/empty.html\""),
378+
Pattern.compile("Wait for load state \"load\""),
379+
});
380+
});
381+
}
362382
}

0 commit comments

Comments
 (0)