-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] How to record video / take screenshot with multiple windows #5633
Comments
I'm not sure what helper functions you are using and what is in // Create context that saves videos
const context = await browser.newContext({ recordVideo: { dir: 'videos/' } });
// Create page and log path where video is saved
const page = await context.newPage();
console.log('Page video: ' + await page.video().path());
// Perform action that creates a page
const [editPage] = await Promise.all([
context.waitForEvent('page'),
editBtn.click() // Always click after waitForEvent, as in all of our docs, other wise you have a bug
]);
// Log path where video is saved
console.log('Edit page video: ' + await editPage.video().path());
// After context.close() you can find video files in the videos folder.
await context.close();
// Here you can read from those paths. |
@pavelfeldman Thanks for your answer. I am using helper from import { Page } from 'playwright-core';
import { CaptureOptions, PageVideoCapture } from './PageVideoCapture';
export declare const saveVideo: (page: Page, savePath: string, options?: CaptureOptions) => Promise<PageVideoCapture>; So, I tried your suggestions. At the end, I get 3 videos (because my app has 3 windows in total, so one video for one page). But the tests can't be completed even though I used
I followed the suggested output, but nothing was opened at the end In this case, it is not possible to record only one video for the whole test suite, isn't it. |
With the playwright api you'll have one video file per page. |
The app I am writing tests, has multiple windows. For example, first I need to login on
MainPage
, click button Edit, then second pageEditPage
will be opened, and the rest of actions happen on second pageEditPage
I have written method to take video with chromium of the whole test flow from begin to end, but when the EditPage opens, the video is still focused on MainPage. The same goes for screenshot, when test fails on EditPage, the screenshot is still taken on MainPage
Below is part of my code:
As I see the problem is,
page
is the input of functionrecordeVideo
andtakeScreenshot
, that's why they don't take video or screenshot oneditPage
.How can I record or take screenshot with multiple windows?
Thanks in advance.
The text was updated successfully, but these errors were encountered: