import { Page, test as testBase } from '@playwright/test';
import { pageObject } from 'pages';
let contextPage: Page = null;
export const test = testBase.extend<{
pageObject: PageObject;
}>({
page: async ({browser}, use) => {
contextPage = await browser.newPage();
await use(contextPage);
},
pageObject: async ({ page }, use) => {
await use(new PageObject(page));
},
});
export const expect = test.expect;
The problem is that the video webm file isn't being generated in test-results when running the test with this code. It's quite puzzling because the video generation seems to work fine if I remove the 'page' part from the 'test' configuration. I'd really appreciate it if someone could shed some light on why this happens and if there's a solution to get the video webm file to generate even with the 'page' included. Thanks in advance for any help!
This thread is trying to answer question "Why is the video webm file not being generated in test-results when running the test with a specific code and how can this issue be resolved?"
Thanks @skorp32 . I gave it a shot, but unfortunately it still didn't seem to have generated. Could you please confirm if I am approaching this correctly?
import { Page, test as testBase } from '@playwright/test';
import { pageObject } from 'pages';
let contextPage: Page = null;
export const test = testBase.extend<{
pageObject: PageObject;
}>({
page: async ({browser}, use) => {
contextPage = await browser.newPage();
await use(contextPage);
await contextPage.close();
},
pageObject: async ({ page }, use) => {
await use(new PageObject(page));
},
});
export const expect = test.expect;
It appears to be generating video correctly when using 'context' instead of 'browser':
import { Page, test as testBase } from '@playwright/test';
import { pageObject } from 'pages';
let contextPage: Page = null;
export const test = testBase.extend<{
pageObject: PageObject;
}>({
page: async ({ context }, use) => {
contextPage = await context.newPage();
await use(contextPage);
},
pageObject: async ({ page }, use) => {
await use(new PageObject(page));
},
});
export const expect = test.expect;
Why might this be the case? The 'recordVideo' option appear to be missing when I console.log the 'browser.page' object
Console.log of (browser.newPage()):
_ownerPage: [Circular *1],
_ownerPage: undefined,
_closedPromise: Promise { <pending> },
_closedPromise: Promise { <pending> },
_options: {
_options: {
acceptDownloads: true,
acceptDownloads: true,
ignoreHTTPSErrors: true,
ignoreHTTPSErrors: true,
javaScriptEnabled: true,
javaScriptEnabled: true,
locale: 'en-US',
locale: 'en-US',
storageState: [Object],
storageState: [Object],
viewport: [Object],
viewport: [Object],
baseURL: 'http://local',
baseURL: 'http://local',
serviceWorkers: 'allow',
serviceWorkers: 'allow',
recordVideo: [Object],
noDefaultViewport: false,
noDefaultViewport: false,
extraHTTPHeaders: undefined,
extraHTTPHeaders: undefined,
recordHar: undefined
recordHar: undefined
},
Console.log of (context.newPage()):
_ownerPage: undefined,
_closedPromise: Promise { <pending> },
_closedPromise: Promise { <pending> },
_options: {
_options: {
acceptDownloads: true,
acceptDownloads: true,
ignoreHTTPSErrors: true,
ignoreHTTPSErrors: true,
javaScriptEnabled: true,
javaScriptEnabled: true,
locale: 'en-US',
locale: 'en-US',
storageState: [Object],
storageState: [Object],
viewport: [Object],
viewport: [Object],
baseURL: 'http:local',
baseURL: 'http://local',
serviceWorkers: 'allow',
serviceWorkers: 'allow',
recordVideo: [Object],
noDefaultViewport: false,
noDefaultViewport: false,
extraHTTPHeaders: undefined,
extraHTTPHeaders: undefined,
recordHar: undefined
recordHar: undefined
},
},
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].