Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we don't use underscore in the var names.

withTitle("Wait for load state \"" + state.toString().toLowerCase() + "\"", () -> {
withWaitLogging("Page.waitForLoadState", logger -> {
mainFrame.waitForLoadStateImpl(state, convertType(options, Frame.WaitForLoadStateOptions.class), logger);
return null;
});
});
}

Expand Down
20 changes: 20 additions & 0 deletions playwright/src/test/java/com/microsoft/playwright/TestTracing.java
Original file line number Diff line number Diff line change
Expand Up @@ -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\""),
});
});
}
}
Loading