Skip to content

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

cubic comments

2pacdd23030bc598
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 1f9aa35aa..ffc03d1da 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -547,7 +547,7 @@ class BrowserSession(BaseModel):
)
else:
- raise e
+ raise
update_tab_focus_script = """
// --- Method 1: visibilitychange event (unfortunately *all* tabs are always marked visible by playwright, usually does not fire) ---
diff --git a/examples/features/multiple_tasks.py b/examples/features/multiple_tasks.py
index 9c9c5e33f..ec5f09764 100644
--- a/examples/features/multiple_tasks.py
+++ b/examples/features/multiple_tasks.py
@@ -24,31 +24,31 @@ llm = ChatGoogleGenerativeAI(model='gemini-2.0-flash', api_key=SecretStr(api_key
async def main():
async with async_playwright() as p:
- try:
- browser = await p.chromium.launch(
- headless=False,
- )
-
- context = await browser.new_context(
- viewport={"width": 1502, "height": 853},
- ignore_https_errors=True,
- )
-
- agent = Agent(
- browser_session=BrowserSession(
- browser_context=context,
- ),
- task="Go to https://browser-use.com/",
- llm=llm,
- )
+ browser = await p.chromium.launch(
+ headless=False,
+ )
+
+ context = await browser.new_context(
+ viewport={"width": 1502, "height": 853},
+ ignore_https_errors=True,
+ )
+
+ agent = Agent(
+ browser_session=BrowserSession(
+ browser_context=context,
+ ),
+ task="Go to https://browser-use.com/",
+ llm=llm,
+ )
+ try:
result = await agent.run()
print(f"First task was {'successful' if result.is_successful else 'not successful'}")
if not result.is_successful:
raise RuntimeError("Failed to navigate to the initial page.")
- agent.add_new_task("Navigate to the documenation page")
+ agent.add_new_task("Navigate to the documentation page")
result = await agent.run()
print(f"Second task was {'successful' if result.is_successful else 'not successful'}")