fix(screencast): auto-save video when page closes without stop#41744
Open
sarang-code2 wants to merge 1 commit into
Open
fix(screencast): auto-save video when page closes without stop#41744sarang-code2 wants to merge 1 commit into
sarang-code2 wants to merge 1 commit into
Conversation
When using page.screencast.start({ path }), if the page closes before
stop() is called, the video file was never saved. The server already
stops the recording gracefully, but the client never called
artifact.saveAs().
Listen for Events.Page.Close in the client Screencast constructor and
auto-save the artifact when the page closes while a recording is active.
Fixes microsoft#41608
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #41608
Problem
When using
page.screencast.start({ path: 'video.webm' }), if the page closes beforepage.screencast.stop()is called, the video file is never saved to disk. The server already stops the recording gracefully, but the client never callsartifact.saveAs()to write the file.This makes it impossible to record a video showing "the window closing when a button is pressed."
Solution
Listen for
Events.Page.Closein the client-sideScreencastconstructor. When the page closes while a recording is active (with apathoption), automatically save the artifact to the specified path.Changes:
packages/playwright-core/src/client/screencast.ts— Register a one-timePage.Closelistener that auto-saves the artifacttests/library/screencast.spec.ts— Add test verifying auto-save on page closeUsage