mirror of
https://github.com/microsoft/playwright-java.git
synced 2026-03-31 20:02:48 +00:00
This commit is contained in:
parent
0585e0d108
commit
7fb2ff34c0
@ -19,8 +19,11 @@ package com.microsoft.playwright;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@ -101,4 +104,25 @@ public class TestScreencast extends TestBase {
|
||||
Path videoPath = page.video().path();
|
||||
assertFalse(Files.exists(videoPath));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldWaitForVideoFinishWhenPageIsClosed(@TempDir Path videosDir) throws IOException {
|
||||
try (Browser browser = browserType.launch(createLaunchOptions())) {
|
||||
BrowserContext context = browser.newContext(
|
||||
new Browser.NewContextOptions()
|
||||
.setRecordVideoDir(videosDir)
|
||||
.setRecordVideoSize(320, 240)
|
||||
.setViewportSize(320, 240));
|
||||
Page page = context.newPage();
|
||||
page.evaluate("() => document.body.style.backgroundColor = 'red'");
|
||||
page.waitForTimeout(500);
|
||||
// First close page manually.
|
||||
page.close();
|
||||
context.close();
|
||||
}
|
||||
List<Path> files = Files.list(videosDir).collect(Collectors.toList());
|
||||
assertEquals(1, files.size());
|
||||
assertTrue(Files.exists(files.get(0)));
|
||||
assertTrue(Files.size(files.get(0)) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
1.11.0-1620331022000
|
||||
1.11.0-1621402998000
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user