PlaywrightBrowserController
Hierarchy
- BrowserController
- PlaywrightBrowserController
Index
Methods
__init__
Initialize a new instance.
Parameters
browser: Browser | PlaywrightPersistentBrowser
The browser instance to control.
optionalkeyword-onlymax_open_pages_per_browser: int = 20
The maximum number of pages that can be open at the same time.
optionalkeyword-onlyuse_incognito_pages: bool = False
By default pages share the same browser context. If set to True each page uses its own context that is destroyed once the page is closed or crashes.
optionalkeyword-onlyheader_generator: HeaderGenerator | None = _DEFAULT_HEADER_GENERATOR
An optional
HeaderGenerator
instance used to generate and manage HTTP headers for requests made by the browser. By default, a predefined header generator is used. Set toNone
to disable automatic header modifications.optionalkeyword-onlyfingerprint_generator: FingerprintGenerator | None = None
An optional instance of implementation of
FingerprintGenerator
that is used to generate browser fingerprints together with consistent headers.
Returns None
close
Close the browser.
Parameters
optionalkeyword-onlyforce: bool = False
Whether to force close all open pages before closing the browser.
Returns None
new_page
Create a new page with the given context options.
Parameters
optionalbrowser_new_context_options: Mapping[str, Any] | None = None
Keyword arguments to pass to the browser new context method. These options are provided directly to Playwright's
browser.new_context
method. For more details, refer to the Playwright documentation: https://playwright.dev/python/docs/api/class-browser#browser-new-context.optionalproxy_info: ProxyInfo | None = None
The proxy configuration to use for the new page.
Returns Page
Properties
AUTOMATION_LIBRARY
The name of the automation library that the controller is using.
browser_type
Return the type of the browser.
has_free_capacity
Return if the browser has free capacity to open a new page.
idle_time
Return the idle time of the browser controller.
is_browser_connected
Return if the browser is closed.
last_page_opened_at
Return the time when the last page was opened.
pages
Return the list of opened pages.
pages_count
Return the number of currently open pages.
total_opened_pages
Return the total number of pages opened since the browser was launched.
Controller for managing Playwright browser instances and their pages.
It provides methods to control browser instances, manage their pages, and handle context-specific configurations. It enforces limits on the number of open pages and tracks their state.