playwright-pytest icon indicating copy to clipboard operation
playwright-pytest copied to clipboard

pytest-playwirght uses --video="on" to record video,the recorded video only records the newly opened tab page

Open crazy-yuzhao opened this issue 1 year ago • 4 comments

pytest-playwirght uses --video="on" to record video. The use case steps will open multiple browser tabs. The recorded video only records the newly opened tab page, and does not record the content of the previous tab page. Whether it supports recording videos on multiple browser tabs, and you can control which tab to record videos for.

crazy-yuzhao avatar Apr 16 '24 04:04 crazy-yuzhao

Are you creating multiple contexts? Then it sounds like https://github.com/microsoft/playwright-pytest/issues/111.

This plugin records a video for every page which gets created during a test-run. Could you maybe provide us a code snippet of whats not working?

mxschmitt avatar Apr 16 '24 08:04 mxschmitt

[pytest]

addopts = -vs
                  --screenshot="only-on-failure"
                  --video="on"

from playwright.sync_api import Page
def test_01(page: Page):
    page.goto('https://playwright.dev/')
    with page.expect_popup() as page2_info:
        page.locator('[href="https://github.com/microsoft/playwright"]').first.click()
    page2 = page2_info.value
    print(page2.title())

page uses @pytest.fixture(scope="session")

@pytest.fixture(scope="session")
def page(context: BrowserContext,
         pytestconfig: Any,
         request: pytest.FixtureRequest,
         ) -> Generator[Page, None, None]:
.........

crazy-yuzhao avatar Apr 16 '24 09:04 crazy-yuzhao

what is the exact implementation of your page fixture? We need more information to act on it, ideally something we can run locally with expected and actual outcome.

mxschmitt avatar Apr 25 '24 08:04 mxschmitt

[pytest]

addopts = -vs
                  --screenshot="only-on-failure"
                  --video="on"

from playwright.sync_api import Page
def test_01(page: Page):
    page.goto('https://playwright.dev/')
    with page.expect_popup() as page2_info:
        page.locator('[href="https://github.com/microsoft/playwright"]').first.click()
    page2 = page2_info.value
    print(page2.title())

page uses @pytest.fixture(scope="session")

@pytest.fixture(scope="session")
def page(context: BrowserContext,
         pytestconfig: Any,
         request: pytest.FixtureRequest,
         ) -> Generator[Page, None, None]:
.........

I changed the scope of the fixture on the page to session, and this case(test_01) can be run locally.

crazy-yuzhao avatar Apr 25 '24 09:04 crazy-yuzhao

Closing as part of the triage process since it seemed stale. Please create a new issue with a detailed reproducible or feature request if you still face issues.

mxschmitt avatar May 21 '24 08:05 mxschmitt