Skip to content

Commit 61c2eb4

Browse files
committed
fix(trace): waitForLoadState title
1 parent aee298b commit 61c2eb4

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,10 +1357,13 @@ public JSHandle waitForFunction(String pageFunction, Object arg, WaitForFunction
13571357
}
13581358

13591359
@Override
1360-
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;
1360+
public void waitForLoadState(LoadState _state, WaitForLoadStateOptions options) {
1361+
final LoadState state = _state == null ? LoadState.LOAD : _state;
1362+
withTitle("Wait for load state \"" + state.toString().toLowerCase() + "\"", () -> {
1363+
withWaitLogging("Page.waitForLoadState", logger -> {
1364+
mainFrame.waitForLoadStateImpl(state, 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)