From 6712413a83b6c2b9f57449a0a0830178d975b8e0 Mon Sep 17 00:00:00 2001 From: theCyberTech <84775494+theCyberTech@users.noreply.github.com> Date: Wed, 11 Feb 2026 17:49:32 +0800 Subject: [PATCH] Strengthen stagehand navigate test assertion --- lib/crewai-tools/tests/tools/stagehand_tool_test.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/crewai-tools/tests/tools/stagehand_tool_test.py b/lib/crewai-tools/tests/tools/stagehand_tool_test.py index d2aa5229a..77987ead8 100644 --- a/lib/crewai-tools/tests/tools/stagehand_tool_test.py +++ b/lib/crewai-tools/tests/tools/stagehand_tool_test.py @@ -1,8 +1,9 @@ +import re import sys +from urllib.parse import urlparse from unittest.mock import MagicMock, patch import pytest -from urllib.parse import urlparse # Create mock classes that will be used by our fixture class MockStagehandModule: @@ -171,10 +172,11 @@ def test_navigate_command(mock_run, stagehand_tool): ) # Assertions + assert "Successfully navigated to " in result + # Extract URL from result string and check its host # Example result: "Successfully navigated to https://example.com" - import re - url_match = re.search(r'https?://[^\s]+', result) + url_match = re.search(r"https?://[^\s]+", result) assert url_match is not None parsed = urlparse(url_match.group(0)) assert parsed.hostname == "example.com"