mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03:00
docs(screencast): add a snippet for _videostarted (#3842)
This commit is contained in:
parent
46f9151795
commit
3495842e7f
24
docs/api.md
24
docs/api.md
@ -778,11 +778,33 @@ page.removeListener('request', logRequest);
|
||||
<!-- GEN:stop -->
|
||||
|
||||
#### event: '_videostarted'
|
||||
- <[Object]> Video object.
|
||||
- <[Object]> Video object. Provides access to the video after it has been written to a file.
|
||||
|
||||
**experimental**
|
||||
Emitted when video recording has started for this page. The event will fire only if [`_recordVideos`](#browsernewcontextoptions) option is configured on the parent context.
|
||||
|
||||
An example of recording a video for single page.
|
||||
```js
|
||||
const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
|
||||
|
||||
(async () => {
|
||||
const browser = await webkit.launch({
|
||||
_videosPath: __dirname // Save videos to custom directory
|
||||
});
|
||||
const context = await browser.newContext({
|
||||
_recordVideos: { width: 640, height: 360 }
|
||||
});
|
||||
const page = await context.newPage();
|
||||
const video = await page.waitForEvent('_videostarted');
|
||||
await page.goto('https://github.com/microsoft/playwright');
|
||||
// Video recording will stop automaticall when the page closes.
|
||||
await page.close();
|
||||
// Wait for the path to the video. It will become available
|
||||
// after the video has been completely written to the the file.
|
||||
console.log('Recorded video: ' + await video.path());
|
||||
})();
|
||||
```
|
||||
|
||||
#### event: 'close'
|
||||
|
||||
Emitted when the page closes.
|
||||
|
Loading…
Reference in New Issue
Block a user