Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
more test fixes
Nick Sweeting9760ac76c2b2
diff --git a/tests/ci/test_sequential_agents_reuse.py b/tests/ci/test_sequential_agents_reuse.pyindex fbfe7d5b6..5c8bea46a 100644--- a/tests/ci/test_sequential_agents_reuse.py+++ b/tests/ci/test_sequential_agents_reuse.py@@ -132,21 +132,32 @@ class TestSequentialAgentsReuse:assert browser_session.initializedassert browser_session.browser_context is not None- # Agent 3: Click link to go to page 3+ # Agent 3: Navigate to page 3agent3_actions = [- """{- "thinking": "Clicking link to navigate to page 3",+ f"""{{+ "thinking": "Navigating to page 3","evaluation_previous_goal": "Now on page 2",- "memory": "Need to click link to page 3",- "next_goal": "Click link to go to page 3",+ "memory": "Need to go to page 3",+ "next_goal": "Navigate to page 3",+ "action": [+ {{+ "go_to_url": {{+ "url": "{httpserver.url_for('/page3')}"+ }}+ }}+ ]+ }}""",+ """{+ "thinking": "Confirming navigation",+ "evaluation_previous_goal": "Navigated to page 3",+ "memory": "Should now be on page 3",+ "next_goal": "Confirm on page 3","action": [{- "click_element_by_index": {- "index": 0- }+ "screenshot": {}}]- }"""+ }""",]agent3 = Agent(@@ -154,30 +165,40 @@ class TestSequentialAgentsReuse:llm=create_mock_llm(agent3_actions),browser_session=browser_session,)- history3 = await agent3.run(max_steps=1)+ history3 = await agent3.run(max_steps=2)assert len(history3.history) >= 1- assert history3.history[-1].state.url == httpserver.url_for('/page3')+ # Check that page3 was visited+ urls3 = [h.state.url for h in history3.history if h.state and h.state.url]+ assert httpserver.url_for('/page3') in urls3, f'Expected {httpserver.url_for("/page3")} in URLs: {urls3}'- # Agent 4: Take a screenshot and extract content+ # Agent 4: Extract content from page 3agent4_actions = ["""{- "thinking": "Taking screenshot and extracting content",+ "thinking": "Extracting page content","evaluation_previous_goal": "Successfully navigated to page 3","memory": "On page 3, need to capture content",- "next_goal": "Take screenshot and extract page content",+ "next_goal": "Extract page content","action": [- {"screenshot": {}},{"extract_page_content": {}}]- }"""+ }""",+ """{+ "thinking": "Taking screenshot",+ "evaluation_previous_goal": "Extracted content",+ "memory": "Content extracted, taking screenshot",+ "next_goal": "Take screenshot",+ "action": [+ {"screenshot": {}}+ ]+ }""",]agent4 = Agent(- task='Take a screenshot and extract content',+ task='Extract content from page 3',llm=create_mock_llm(agent4_actions),browser_session=browser_session,)- history4 = await agent4.run(max_steps=2)+ history4 = await agent4.run(max_steps=3)assert len(history4.history) >= 1# Verify all agents completed successfully@@ -319,7 +340,9 @@ class TestSequentialAgentsReuse:# Verify browser is still aliveassert browser_session.initializedassert browser_session.browser_context is not None- assert browser_session.browser_pid == initial_browser_pid # Same browser process+ # Only check browser_pid if it was available initially+ if initial_browser_pid is not None:+ assert browser_session.browser_pid == initial_browser_pid # Same browser process# Create second agent - should work without issuesagent2_actions = [