Skip to content

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

fix clickaction error handling test

Nick Sweeting06488e11ba10
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index feab79ed2..3c92038c9 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -1,9 +1,11 @@
name: test
permissions:
- contents: read
+ actions: read
+ contents: write
pull-requests: write # Allow writing comments on PRs
issues: write # Allow writing comments on issues
statuses: write # Allow writing statuses on PRs
+ discussions: write
on:
push:
diff --git a/tests/ci/test_controller.py b/tests/ci/test_controller.py
index 7a6384877..e19e3105c 100644
--- a/tests/ci/test_controller.py
+++ b/tests/ci/test_controller.py
@@ -268,17 +268,14 @@ class TestControllerIntegration:
async def test_error_handling(self, controller, browser_session):
"""Test error handling when an action fails."""
# Create an action with an invalid index
- invalid_action = {'click_element_by_index': ClickElementAction(index='abc')} # wrong type, expects a number
+ invalid_action = {'click_element_by_index': ClickElementAction(index=999)} # doesn't exist on page
class ClickActionModel(ActionModel):
click_element_by_index: ClickElementAction | None = None
# This should fail since the element doesn't exist
- with pytest.raises(Exception) as excinfo:
- await controller.act(ClickActionModel(**invalid_action), browser_session)
-
- # Verify that an appropriate error is raised
- assert 'does not exist' in str(excinfo.value) or 'Element with index' in str(excinfo.value)
+ result = await controller.act(ClickActionModel(**invalid_action), browser_session)
+ assert result.success is False
async def test_wait_action(self, controller, browser_session):
"""Test that the wait action correctly waits for the specified duration."""