microsoft/playwright-pytest

Change locale without launching a persistent contex

4ydan opened this issue · 2 comments

4ydan commented

I have looked a bit around in the docu and in some issues.
I am having the problem setting a locale across all my contexts. When I use launch_persistent_context it removes the nice folder names when recording video files.

Is there a nice way to just change the locale or not override everything else?

This is what I have

@pytest.fixture(scope="session")
def context(
    browser_type: BrowserType,
    browser_type_launch_args: Dict,
    browser_context_args: Dict
):
    context = browser_type.launch_persistent_context(
        user_data_dir="./data",
        **{
            **browser_type_launch_args,
            **browser_context_args,
            "locale": "de-DE",
            "record_video_dir": "./test-results"
        })
    yield context
    context.close()

Whats the reason you are using launch_persistent_context? If you want to set a custom locale, you can do it like shown here if you replace viewport with locale: https://playwright.dev/python/docs/test-runners#use-custom-viewport-size

4ydan commented

I understand now, thank you.