Skip to content
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

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

Closed
crazy-yuzhao opened this issue Apr 16, 2024 · 5 comments

Comments

@crazy-yuzhao
Copy link

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.

@mxschmitt
Copy link
Member

Are you creating multiple contexts? Then it sounds like #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?

@crazy-yuzhao
Copy link
Author

[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]:
.........

@mxschmitt
Copy link
Member

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.

@crazy-yuzhao
Copy link
Author

[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.

@mxschmitt
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants