File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
main/java/com/microsoft/playwright/impl
test/java/com/microsoft/playwright Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,9 @@ public Path path() {
7272 @ Override
7373 public void saveAs (Path path ) {
7474 page .withLogging ("Video.saveAs" , () -> {
75+ if (!page .isClosed ()) {
76+ throw new PlaywrightException ("Page is not yet closed. Close the page prior to calling saveAs" );
77+ }
7578 try {
7679 waitForArtifact ().saveAs (path );
7780 } catch (PlaywrightException e ) {
Original file line number Diff line number Diff line change @@ -127,4 +127,17 @@ void shouldWaitForVideoFinishWhenPageIsClosed(@TempDir Path videosDir) throws IO
127127 assertTrue (Files .exists (files .get (0 )));
128128 assertTrue (Files .size (files .get (0 )) > 0 );
129129 }
130+
131+ @ Test
132+ void shouldErrorIfPageNotClosedBeforeSaveAs (@ TempDir Path tmpDir ) {
133+ try (Page page = browser .newPage (new Browser .NewPageOptions ().setRecordVideoDir (tmpDir ))) {
134+ page .navigate (server .PREFIX + "/grid.html" );
135+ Path outPath = tmpDir .resolve ("some-video.webm" );
136+ Video video = page .video ();
137+ PlaywrightException exception = assertThrows (PlaywrightException .class , () -> video .saveAs (outPath ));
138+ assertTrue (
139+ exception .getMessage ().contains ("Page is not yet closed. Close the page prior to calling saveAs" ),
140+ exception .getMessage ());
141+ }
142+ }
130143}
You can’t perform that action at this time.
0 commit comments