Skip to content

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

Update wait test

Magnus Müller2552825786ee
diff --git a/tests/ci/test_controller.py b/tests/ci/test_controller.py
index 2778a125f..e36046d42 100644
--- a/tests/ci/test_controller.py
+++ b/tests/ci/test_controller.py
@@ -328,8 +328,33 @@ class TestControllerIntegration:
assert result.extracted_content is not None
assert 'Waiting for' in result.extracted_content
- # Verify that at least 1 second has passed
- assert end_time - start_time >= 0.9 # Allow some timing margin
+ # Verify that less than 0.1 second has passed (because we substract 3 seconds to account for the llm call)
+ assert end_time - start_time <= 0.1 # Allow some timing margin
+
+ # longer wait
+ # Create wait action for 1 second - fix to use a dictionary
+ wait_action = {'wait': {'seconds': 5}} # Corrected format
+
+ class WaitActionModel(ActionModel):
+ wait: dict | None = None
+
+ # Record start time
+ start_time = time.time()
+
+ # Execute wait action
+ result = await controller.act(WaitActionModel(**wait_action), browser_session)
+
+ # Record end time
+ end_time = time.time()
+
+ # Verify the result
+ assert isinstance(result, ActionResult)
+ assert result.extracted_content is not None
+ assert 'Waiting for' in result.extracted_content
+
+ # Verify that we took 2 sec (5s-3s (llm call)= 2s)
+ assert end_time - start_time <= 2.1 # Allow some timing margin
+ assert end_time - start_time >= 1.9 # Allow some timing margin
async def test_go_back_action(self, controller, browser_session, base_url):
"""Test that go_back action navigates to the previous page."""