microsoft/playwright-pytest

[FEATURE] Support for multiple browser contexts in a single test

andersonhowever opened this issue · 1 comments

The current implementation of the Playwright pytest plugin does not natively support the creation and management of multiple browser contexts within a single test. This limitation restricts the ability to perform parallel browser interactions within the same test case, which is essential for more complex testing scenarios, such as comparing two web pages side-by-side or managing different user sessions simultaneously.

Current Workaround:

To achieve multiple contexts, users might create contexts manually within the test body. However, this approach lacks the tracing, screenshot capture, and video recording provided by the plugin's context fixture.

def test_compare_two_pages(browser):
    context1 = browser.new_context()
    page1 = context1.new_page()
    page1.goto("https://example.com")

    context2 = browser.new_context()
    page2 = context2.new_page()
    page2.goto("https://example2.com")

    # Compare page1 and page2...

This should be fixed in v0.5.0: https://pypi.org/project/pytest-playwright/