Skip to content

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

better wait action tests

Nick Sweeting8ddb5a68f546
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index ffc03d1da..c7fce05ad 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -258,8 +258,8 @@ class BrowserSession(BaseModel):
try:
await (self.browser_context or self.browser).close()
logger.info(
- f'🛑 Stopped the Browser '
- f'(keep_alive=False user_data_dir={_log_pretty_path(self.browser_profile.user_data_dir) or "<incognito>"})'
+ f'🛑 Stopped the Browser {self.browser_profile.channel.name.lower()} '
+ f'keep_alive=False user_data_dir={_log_pretty_path(self.browser_profile.user_data_dir) or "<incognito>"} cdp_url={self.cdp_url or self.wss_url} pid={self.browser_pid}'
)
self.browser_context = None
except Exception as e:
@@ -269,7 +269,7 @@ class BrowserSession(BaseModel):
if self.browser_pid:
try:
psutil.Process(pid=self.browser_pid).terminate()
- logger.info(f'⏹ Shut down the browser subprocess with browser_pid={self.browser_pid} (keep_alive=False)')
+ logger.info(f'⏹ Killed the browser subprocess with browser_pid={self.browser_pid} (keep_alive=False)')
self.browser_pid = None
except Exception as e:
if 'NoSuchProcess' not in type(e).__name__:
@@ -296,6 +296,7 @@ class BrowserSession(BaseModel):
Override to customize the set up of the playwright or patchright library object
"""
self.playwright = self.playwright or (await async_playwright().start())
+ # self.playwright = self.playwright or (await async_patchright().start())
# if isinstance(self.playwright, PatchrightPlaywright):
# # patchright handles all its own default args, dont mess with them
diff --git a/tests/ci/test_action_registry.py b/tests/ci/test_action_registry.py
index 5f626cec6..932e7cb59 100644
--- a/tests/ci/test_action_registry.py
+++ b/tests/ci/test_action_registry.py
@@ -1018,36 +1018,6 @@ class TestParameterOrdering:
assert set(action.param_model.model_fields.keys()) == {'query', 'limit'}
-class TestControllerDefaultActions:
- """Test that default Controller actions follow the rules"""
-
- @pytest.mark.asyncio
- async def test_wait_action_no_special_params(self):
- """Test the wait action which has no special params"""
- from browser_use.controller.service import Controller
-
- controller = Controller()
-
- # Find the wait action
- wait_action = None
- for action_name, action in controller.registry.registry.actions.items():
- if 'wait' in action_name.lower() and 'seconds' in str(action.param_model.model_fields):
- wait_action = action
- break
-
- assert wait_action is not None, 'Could not find wait action in controller'
-
- # Check that it has seconds parameter with default
- assert 'seconds' in wait_action.param_model.model_fields
- schema = wait_action.param_model.model_json_schema()
- assert schema['properties']['seconds']['default'] == 3
-
- # Test execution with integer value
- result = await controller.registry.execute_action(wait_action.name, {'seconds': 1})
- assert result.extracted_content is not None
- assert 'Wait' in result.extracted_content or 'wait' in result.extracted_content
-
-
# Test runner for manual execution
if __name__ == '__main__':
# Run a simple test manually
diff --git a/tests/ci/test_controller.py b/tests/ci/test_controller.py
index fbd1055ab..252b024d6 100644
--- a/tests/ci/test_controller.py
+++ b/tests/ci/test_controller.py
@@ -292,6 +292,20 @@ class TestControllerIntegration:
@pytest.mark.asyncio
async def test_wait_action(self, controller, browser_session):
"""Test that the wait action correctly waits for the specified duration."""
+
+ # verify that it's in the default action set
+ wait_action = None
+ for action_name, action in controller.registry.registry.actions.items():
+ if 'wait' in action_name.lower() and 'seconds' in str(action.param_model.model_fields):
+ wait_action = action
+ break
+ assert wait_action is not None, 'Could not find wait action in controller'
+
+ # Check that it has seconds parameter with default
+ assert 'seconds' in wait_action.param_model.model_fields
+ schema = wait_action.param_model.model_json_schema()
+ assert schema['properties']['seconds']['default'] == 3
+
# Create wait action for 1 second - fix to use a dictionary
wait_action = {'wait': {'seconds': 1}} # Corrected format
@@ -309,6 +323,7 @@ class TestControllerIntegration:
# Verify the result
assert isinstance(result, ActionResult)
+ assert result.extracted_content is not None
assert 'Waiting for' in result.extracted_content
# Verify that at least 1 second has passed