How can i store my current context to load later as persistent context?: browser_context.launch_persistent_context(user_data_dir)

Viewed 28

I want to use chrome extensions in my playwright python script. From the docs https://playwright.dev/python/docs/chrome-extensions I realize it requires me to launch persistent context from defined user_dir. What path is this user_dir?

    context = playwright.chromium.launch_persistent_context(
    user_data_dir,
    headless=False,
    args=[
        f"--disable-extensions-except={path_to_extension}",
        f"--load-extension={path_to_extension}",
    ],
)

I want to use cookies and extensions with my browser. I achieve the former with browser_context.storage_state(path='cookies.json'). Is there a way to do both tasks with single method? Thank you.

0 Answers
Related