Rayrun
← Back to Discord Forum

Strange issue with reporting

cherry_picker_01posted in #help-playwright
Open in Discord
cherry_picker_01
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?"

14 replies

If you're creating context manually then you need to call browserContext.close() to save the video

cherry_picker_01

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;

hard to say, I'm not sure what you're tryign to achive with:

let contextPage: Page = null;


  page: async (use) => {
    await use(contextPage);
    await contextPage.close();
  },

is this a full code? where and how is contextPage created?

and according to docs you need to close browser context

cherry_picker_01

Would it be alright if I sent you the code via DM

sure

cherry_picker_01

Dmed.

cherry_picker_01

@mxschmitt is this a known limitation/bug?

cherry_picker_01

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

cherry_picker_01

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
    },
    },
cherry_picker_01

@mxschmitt @pavelfeldman Please, kindly let me know if this can be raised as a bug, or if there's a viable workaround available. Your input would be highly valuable.

cherry_picker_01

Unfortunately, switching from 'browser' to 'context' prevents me from using the 'beforeAll' hook. Error: Error: "context" and "page" fixtures are not supported in beforeAll. Use browser.newContext() instead.... is there a way to fix it so that I can still use the same configuration?

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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 luc@ray.run.