Morph is OpenAI-compatible, so you can use it directly with browser-use’s ChatOpenAI:
from browser_use import Agent, ChatOpenAIimport asyncioimport os# Point to Morph API (OpenAI-compatible endpoint)llm = ChatOpenAI( model="morph-computer-use-v0", api_key="YOUR_API_KEY", base_url="https://api.morphllm.com/v1")agent = Agent( task="Go to amazon.com, search for 'laptop', and give me the title of the first result", llm=llm)async def main(): result = await agent.run(max_steps=10) print(result)asyncio.run(main())
from browser_use import Agent, ChatOpenAIimport asyncioimport osllm = ChatOpenAI( model="morph-computer-use-v0", api_key="YOUR_API_KEY", base_url="https://api.morphllm.com/v1")async def test_ecommerce(): # Test search functionality agent = Agent( task=( "Go to amazon.com, search for 'wireless mouse', " "click on the first result, and tell me the price" ), llm=llm ) result = await agent.run(max_steps=15) print(f"Result: {result}") # Test checkout flow checkout_agent = Agent( task=( "Go to mystore.com, add the first product to cart, " "go to checkout, and verify the cart total is displayed" ), llm=llm ) checkout_result = await checkout_agent.run(max_steps=20) print(f"Checkout test: {checkout_result}")asyncio.run(test_ecommerce())
Use case: Automated regression testing for e-commerce platforms
Form Submission Testing
Test complex forms and multi-step flows:
from browser_use import Agent, ChatOpenAIimport asyncioimport osllm = ChatOpenAI( model="morph-computer-use-v0", api_key="YOUR_API_KEY", base_url="https://api.morphllm.com/v1")async def test_form_submission(): agent = Agent( task=( "Go to example.com/contact, fill in the form with: " "name='John Doe', email='john@example.com', " "message='Test message', then submit and verify success message appears" ), llm=llm ) result = await agent.run(max_steps=12) if "success" in result.lower(): print("✅ Form submission successful") else: print("❌ Form submission failed") print(result)asyncio.run(test_form_submission())
Use case: Continuous testing of lead generation forms
Authentication Testing
Test login flows and authenticated sessions:
from browser_use import Agent, ChatOpenAIimport asyncioimport osllm = ChatOpenAI( model="morph-computer-use-v0", api_key="YOUR_API_KEY", base_url="https://api.morphllm.com/v1")async def test_login_flow(): agent = Agent( task=( "Go to myapp.com/login, enter email 'test@example.com' " "and password 'TestPass123', click login, and verify " "the dashboard page loads with the welcome message" ), llm=llm ) result = await agent.run(max_steps=10) print(f"Login test result: {result}")asyncio.run(test_login_flow())
Security note: Use test accounts only. Never use real credentials in automated tests.
Data Extraction
Extract structured data from web pages:
from browser_use import Agent, ChatOpenAIimport asyncioimport jsonimport osllm = ChatOpenAI( model="morph-computer-use-v0", api_key="YOUR_API_KEY", base_url="https://api.morphllm.com/v1")async def extract_product_data(): agent = Agent( task=( "Go to amazon.com/product/B08N5WRWNW, extract the product title, " "price, rating, and number of reviews. Return as JSON format." ), llm=llm ) result = await agent.run(max_steps=8) # Parse the extracted data try: data = json.loads(result) print(f"Product: {data.get('title')}") print(f"Price: {data.get('price')}") print(f"Rating: {data.get('rating')}") except json.JSONDecodeError: print("Raw result:", result)asyncio.run(extract_product_data())
Use case: Competitive pricing analysis, product monitoring
from browser_use import Agent, ChatOpenAIimport asyncioimport osllm = ChatOpenAI( model="morph-computer-use-v0", api_key="YOUR_API_KEY", base_url="https://api.morphllm.com/v1")async def run_test(test_name: str, task: str): agent = Agent(task=task, llm=llm) result = await agent.run(max_steps=10) return {"test": test_name, "result": result}async def parallel_tests(): tests = [ ("Homepage", "Go to myapp.com and verify the hero section loads"), ("Pricing", "Go to myapp.com/pricing and count the pricing tiers"), ("Contact", "Go to myapp.com/contact and verify the form is present") ] # Run all tests in parallel results = await asyncio.gather(*[ run_test(name, task) for name, task in tests ]) for result in results: print(f"{result['test']}: {result['result']}")asyncio.run(parallel_tests())
Use Morph SDK if: You’re building in TypeScript and want live sessions, recordings, or async task trackingUse browser-use if: You’re in Python and want the browser-use agent interface
Error: Agent gives up or can’t complete the taskFix: Make task more specific and increase steps
# ❌ Too vaguetask = "Test the app"# ✅ Specific and actionabletask = ( "Go to myapp.com, click the 'Sign Up' button, " "verify the registration form appears with email and password fields")# Use enough steps for the complexityagent = Agent(task=task, llm=llm)result = await agent.run(max_steps=15) # Adjust based on task
# Install all browsersplaywright install# Or install specific browserplaywright install chromium# For CI/CD, install system dependenciesplaywright install-deps