Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Merge branch 'bug/294-newlines-in-selectors' of https://github.com/neoromantic/browser-use into neoromantic-bug/294-newlines-in-selectors

magmueller3fd3beb4d52c
diff --cc browser_use/browser/context.py
index 16c2b6559,bd429bcb1..09263abf9
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@@ -78,11 -78,8 +78,11 @@@ class BrowserContextConfig
trace_path: None
Path to save trace files. It will auto name the file with the TRACE_PATH/{context_id}.zip
- locale: None
- Specify user locale, for example en-GB, de-DE, etc. Locale will affect navigator.language value, Accept-Language request header value as well as number and date formatting rules. If not provided, defaults to the system default locale.
-
- locale: None
- Specify user locale, for example en-GB, de-DE, etc. Locale will affect navigator.language value, Accept-Language request header value as well as number and date formatting rules. If not provided, defaults to the system default locale.
++ locale: None
++ Specify user locale, for example en-GB, de-DE, etc. Locale will affect navigator.language value, Accept-Language request header value as well as number and date formatting rules. If not provided, defaults to the system default locale.
++
+ user_agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36'
+ custom user agent to use.
"""
cookies_file: str | None = None
@@@ -101,8 -98,7 +101,8 @@@
save_recording_path: str | None = None
trace_path: str | None = None
locale: str | None = None
+ user_agent: str = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36'
-
+
@dataclass
class BrowserSession:
@@@ -550,7 -549,7 +550,9 @@@ class BrowserContext
return session.cached_state
- async def _update_state(self, use_vision: bool = False, focus_element: int = -1) -> BrowserState:
- async def _update_state(self, use_vision: bool = False) -> BrowserState:
++ async def _update_state(
++ self, use_vision: bool = False, focus_element: int = -1
++ ) -> BrowserState:
"""Update and return state."""
session = await self.get_session()