Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/proxy_lite/browser/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ def __init__(
viewport_width: int = 1280,
viewport_height: int = 720,
headless: bool = True,
storage_state: Optional[str] = None,
):
self.viewport_width = viewport_width
self.viewport_height = viewport_height
self.headless = headless
self.playwright: Playwright | None = None
self.browser: Browser | None = None
self.context: BrowserContext | None = None
self.storage_state = storage_state
self._exit_stack: AsyncExitStack | None = None

self.poi_elements: list = Field(default_factory=list)
Expand All @@ -103,6 +105,7 @@ async def __aenter__(self) -> Self:
self.browser = await self.playwright.chromium.launch(headless=self.headless)
self.context = await self.browser.new_context(
viewport={"width": self.viewport_width, "height": self.viewport_height},
storage_state=self.storage_state,
)
await self.context.new_page()
self.context.set_default_timeout(60_000)
Expand Down
4 changes: 4 additions & 0 deletions src/proxy_lite/environments/webbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from functools import cached_property
from typing import Any, Literal, Optional, Self

from pydantic import Field

from proxy_lite.browser.browser import BrowserSession
from proxy_lite.environments.environment_base import (
Action,
Expand All @@ -28,6 +30,7 @@ class WebBrowserEnvironmentConfig(BaseEnvironmentConfig):
browserbase_timeout: int = 7200
headless: bool = True
keep_original_image: bool = False
storage_state: Optional[str] = Field(default=None, description="Path to a file containing cookies and other browser storage state.")
no_pois_in_image: bool = False


Expand All @@ -46,6 +49,7 @@ async def __aenter__(self) -> Self:
viewport_width=self.config.viewport_width,
viewport_height=self.config.viewport_height,
headless=self.config.headless,
storage_state=self.config.storage_state,
)
await self.browser.__aenter__()
# Initialize other resources if necessary
Expand Down