Skip to main content

PlaywrightPersistentBrowser

A wrapper for Playwright's Browser that operates with a persistent context.

It utilizes Playwright's persistent browser context feature, maintaining user data across sessions. While it follows the same interface as Playwright's Browser class, there is no abstract base class enforcing this. There is a limitation that only a single persistent context is allowed.

Index

Methods

__init__

  • __init__(browser_type, user_data_dir, browser_launch_options): None
  • Parameters

    • browser_type: BrowserType
    • user_data_dir: (str | Path) | None
    • browser_launch_options: dict[str, Any]

    Returns None

close

  • async close(kwargs): None
  • Close browser by closing its context.


    Parameters

    • kwargs: Any

    Returns None

is_connected

  • is_connected(): bool
  • Returns bool

new_browser_cdp_session

  • async new_browser_cdp_session(): CDPSession
  • Returns CDPSession

new_context

  • async new_context(context_options): BrowserContext
  • Create persistent context instead of regular one. Merge launch options with context options.


    Parameters

    • context_options: Any

    Returns BrowserContext

new_page

  • async new_page(kwargs): Page
  • Parameters

    • kwargs: Any

    Returns Page

start_tracing

  • async start_tracing(kwargs): None
  • Parameters

    • kwargs: Any

    Returns None

stop_tracing

  • async stop_tracing(kwargs): bytes
  • Parameters

    • kwargs: Any

    Returns bytes

Properties

browser_type

browser_type: BrowserType

contexts

contexts: list[BrowserContext]

version

version: str