1
0
mirror of synced 2026-08-05 15:06:54 +00:00

fix: prevent video.saveAs() from hanging (#1020)

This commit is contained in:
Yury Semikhatsky
2022-08-01 15:01:43 -07:00
committed by GitHub
parent 436fc12609
commit 64f7a059af
2 changed files with 16 additions and 0 deletions
@@ -72,6 +72,9 @@ class VideoImpl implements Video {
@Override
public void saveAs(Path path) {
page.withLogging("Video.saveAs", () -> {
if (!page.isClosed()) {
throw new PlaywrightException("Page is not yet closed. Close the page prior to calling saveAs");
}
try {
waitForArtifact().saveAs(path);
} catch (PlaywrightException e) {
@@ -127,4 +127,17 @@ public class TestScreencast extends TestBase {
assertTrue(Files.exists(files.get(0)));
assertTrue(Files.size(files.get(0)) > 0);
}
@Test
void shouldErrorIfPageNotClosedBeforeSaveAs(@TempDir Path tmpDir) {
try (Page page = browser.newPage(new Browser.NewPageOptions().setRecordVideoDir(tmpDir))) {
page.navigate(server.PREFIX + "/grid.html");
Path outPath = tmpDir.resolve("some-video.webm");
Video video = page.video();
PlaywrightException exception = assertThrows(PlaywrightException.class, () -> video.saveAs(outPath));
assertTrue(
exception.getMessage().contains("Page is not yet closed. Close the page prior to calling saveAs"),
exception.getMessage());
}
}
}