Skip to main content

Video

当使用 recordVideo 选项创建浏览器上下文时,每个页面都有一个与其关联的视频对象。

¥When browser context is created with the recordVideo option, each page has a video object associated with it.

console.log(await page.video().path());

方法

¥Methods

delete

Added in: v1.11 video.delete

删除视频文件。如有必要,将等待视频完成。

¥Deletes the video file. Will wait for the video to finish if necessary.

用法

¥Usage

await video.delete();

返回

¥Returns


path

Added in: v1.8 video.path

返回该视频将录制到的文件系统路径。关闭浏览器上下文后,视频保证被写入文件系统。远程连接时此方法会抛出异常。

¥Returns the file system path this video will be recorded to. The video is guaranteed to be written to the filesystem upon closing the browser context. This method throws when connected remotely.

用法

¥Usage

await video.path();

返回

¥Returns


saveAs

Added in: v1.11 video.saveAs

将视频保存到用户指定的路径。在视频仍在播放时或页面关闭后调用此方法是安全的。此方法会等到页面关闭并且视频完全保存。

¥Saves the video to a user-specified path. It is safe to call this method while the video is still in progress, or after the page has closed. This method waits until the page is closed and the video is fully saved.

用法

¥Usage

await video.saveAs(path);

参数

¥Arguments

视频应保存的路径。

¥Path where the video should be saved.

返回

¥Returns