-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #611: Fix ImportError in browser_use/agent/tests.py (#611) #624
Conversation
I opened a Pull Request with the following: 🔄 1 test added. 🔄 Test UpdatesI've added 1 tests. They all pass ☑️
No existing tests required updates. 🐛 Bug DetectionNo bugs detected in your changes. Good job! 🛠️ Test Results1/8 tests passed tests/test_dropdown.py View errortests/test_dropdown.py:20: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_dropdown_complex.py View errortests/test_dropdown_complex.py:20: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_dropdown_error.py View errortests/test_dropdown_error.py:20: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_gif_path.py View errortests/test_gif_path.py:19: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_models.py View errortests/test_models.py:54: in <module>
ChatOpenAI(
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_react_dropdown.py View errortests/test_react_dropdown.py:20: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
tests/test_vision.py View errortests/test_vision.py:25: in <module>
llm = ChatOpenAI(model='gpt-4o')
/usr/local/lib/python3.11/site-packages/langchain_core/load/serializable.py:125: in __init__
super().__init__(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/langchain_openai/chat_models/base.py:622: in validate_environment
self.root_client = openai.OpenAI(**client_params, **sync_specific) # type: ignore[arg-type]
/usr/local/lib/python3.11/site-packages/openai/_client.py:110: in __init__
raise OpenAIError(
E openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
☂️ Coverage ImprovementsCoverage improvements by file:
🎨 Final Touches
Settings | Logs | CodeBeaver |
Fix browser-use#611: Fix ImportError in browser_use/agent/tests.py (browser-use#611)
Pull Request: Fix Agent Test by Adding
ExtractPageContentAction
This PR resolves #611
Summary
This PR fixes failing agent tests by introducing
ExtractPageContentAction
into the controller. The test cases require this action to properly validate the model outputs.Changes Made
ExtractPageContentAction
inbrowser_use/controller/views.py
to support test validation.AgentHistory
samples to include meaningful interactions (xpath
values).browser_use/agent/tests.py
) to includeextract_page_content
in expected outputs.Why This Change?
ExtractPageContentAction
, leading to assertion errors.Impact & Risk
✅ Low risk – This change only introduces an action already referenced in tests.
✅ Backward compatible – No existing logic is modified, only extended to support test cases.
Next Steps
Let me know if you need any adjustments! 🚀
❌Before the Changes
Even before add the

ExtractPageContentAction
, it has 8 errors occur, this pull request will fix the bugs in the test case:✅ After the Changes