Skip to content

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

Fix test to properly check for click failures

Magnus Mülleradcac192593e
diff --git a/tests/ci/browser/test_dom_serializer.py b/tests/ci/browser/test_dom_serializer.py
index 49d1e271c..3b9648748 100644
--- a/tests/ci/browser/test_dom_serializer.py
+++ b/tests/ci/browser/test_dom_serializer.py
@@ -281,8 +281,13 @@ class TestDOMSerializer:
# Helper to call tools.click(index) and verify it worked
async def click(index: int, element_description: str):
result = await tools.registry.execute_action('click', {'index': index}, browser_session=browser_session)
+ # Check both error field and extracted_content for failure messages
if result.error:
raise AssertionError(f'Click on {element_description} [{index}] failed: {result.error}')
+ if result.extracted_content and (
+ 'not available' in result.extracted_content.lower() or 'failed' in result.extracted_content.lower()
+ ):
+ raise AssertionError(f'Click on {element_description} [{index}] failed: {result.extracted_content}')
print(f' ✓ {element_description} [{index}] clicked successfully')
return result