@@ -35,26 +35,26 @@ def __init__(
3535 self ,
3636 * ,
3737 browser_type : BrowserType = 'chromium' ,
38- browser_options : Mapping [str , Any ] | None = None ,
39- page_options : Mapping [str , Any ] | None = None ,
38+ browser_launch_options : Mapping [str , Any ] | None = None ,
39+ browser_new_context_options : Mapping [str , Any ] | None = None ,
4040 max_open_pages_per_browser : int = 20 ,
4141 ) -> None :
4242 """A default constructor.
4343
4444 Args:
4545 browser_type: The type of browser to launch ('chromium', 'firefox', or 'webkit').
46- browser_options : Keyword arguments to pass to the browser launch method. These options are provided
46+ browser_launch_options : Keyword arguments to pass to the browser launch method. These options are provided
4747 directly to Playwright's `browser_type.launch` method. For more details, refer to the Playwright
4848 documentation: https://playwright.dev/python/docs/api/class-browsertype#browser-type-launch.
49- page_options : Keyword arguments to pass to the page object is set at the playwright context level.
50- These options are provided directly to Playwright's `browser.new_context` method. For more details,
51- refer to the Playwright documentation: https://playwright.dev/python/docs/api/class-browser#browser-new-context.
49+ browser_new_context_options : Keyword arguments to pass to the browser new context method. These options
50+ are provided directly to Playwright's `browser.new_context` method. For more details, refer to the
51+ Playwright documentation: https://playwright.dev/python/docs/api/class-browser#browser-new-context.
5252 max_open_pages_per_browser: The maximum number of pages that can be opened in a single browser instance.
5353 Once reached, a new browser instance will be launched to handle the excess.
5454 """
5555 self ._browser_type = browser_type
56- self ._browser_options = browser_options or {}
57- self ._page_options = page_options or {}
56+ self ._browser_launch_options = browser_launch_options or {}
57+ self ._browser_new_context_options = browser_new_context_options or {}
5858 self ._max_open_pages_per_browser = max_open_pages_per_browser
5959
6060 self ._playwright_context_manager = async_playwright ()
@@ -75,13 +75,25 @@ def browser_type(self) -> BrowserType:
7575
7676 @property
7777 @override
78- def browser_options (self ) -> Mapping [str , Any ]:
79- return self ._browser_options
78+ def browser_launch_options (self ) -> Mapping [str , Any ]:
79+ """Return the options for the `browser.launch` method.
80+
81+ Keyword arguments to pass to the browser launch method. These options are provided directly to Playwright's
82+ `browser_type.launch` method. For more details, refer to the Playwright documentation:
83+ https://playwright.dev/python/docs/api/class-browsertype#browser-type-launch.
84+ """
85+ return self ._browser_launch_options
8086
8187 @property
8288 @override
83- def page_options (self ) -> Mapping [str , Any ]:
84- return self ._page_options
89+ def browser_new_context_options (self ) -> Mapping [str , Any ]:
90+ """Return the options for the `browser.new_context` method.
91+
92+ Keyword arguments to pass to the browser new context method. These options are provided directly to Playwright's
93+ `browser.new_context` method. For more details, refer to the Playwright documentation:
94+ https://playwright.dev/python/docs/api/class-browser#browser-new-context.
95+ """
96+ return self ._browser_new_context_options
8597
8698 @property
8799 @override
@@ -117,11 +129,11 @@ async def new_browser(self) -> PlaywrightBrowserController:
117129 raise RuntimeError ('Playwright browser plugin is not initialized.' )
118130
119131 if self ._browser_type == 'chromium' :
120- browser = await self ._playwright .chromium .launch (** self ._browser_options )
132+ browser = await self ._playwright .chromium .launch (** self ._browser_launch_options )
121133 elif self ._browser_type == 'firefox' :
122- browser = await self ._playwright .firefox .launch (** self ._browser_options )
134+ browser = await self ._playwright .firefox .launch (** self ._browser_launch_options )
123135 elif self ._browser_type == 'webkit' :
124- browser = await self ._playwright .webkit .launch (** self ._browser_options )
136+ browser = await self ._playwright .webkit .launch (** self ._browser_launch_options )
125137 else :
126138 raise ValueError (f'Invalid browser type: { self ._browser_type } ' )
127139
0 commit comments