Real-world example from the Browser Use repository - automated grocery shopping on Migros Online:
import asynciofrom browser_use import Agent, ChatOpenAIfrom dotenv import load_dotenvload_dotenv()task = """### Prompt for Shopping Agent – Migros Online Grocery Order**Objective:**Visit Migros Online (https://www.migros.ch/en), search for grocery items, add them to cart, select delivery window, and complete checkout.**Important:**- Don't buy more than needed for each article- After search, click the "+" button to add items to basket- If basket side window opens, close it with X button on top right---### Step 1: Navigate to the Website- Open https://www.migros.ch/en- Verify you're logged in---### Step 2: Add Items to the Basket#### Shopping List:**Meat & Dairy:**- Beef Minced meat (1 kg)- Gruyère cheese (grated preferably)- 2 liters full-fat milk- Butter (cheapest available)**Vegetables:**- Carrots (1kg pack)- Celery- Leeks (1 piece)- 1 kg potatoesCheck the basket on top right to verify correct items.**Fruits:**- 2 lemons- Oranges (for snacking)**Pantry Items:**- Lasagna sheets- Tahini- Tomato paste (below CHF2)- Black pepper refill (not with the mill)- 2x 1L Oatly Barista (oat milk)- 1 pack of eggs (10 egg package)#### Ingredients I already have (DO NOT purchase):- Olive oil, garlic, canned tomatoes, dried oregano, bay leaves, salt, chili flakes, flour, nutmeg, cumin---### Step 3: Handling Unavailable Items- If an item is out of stock, find the best alternative- Use recipe context to choose substitutions: - **Pasta Bolognese & Lasagna:** Minced meat, tomato paste, lasagna sheets, milk, Gruyère cheese - **Hummus:** Tahini, chickpeas, lemon juice, olive oil - **Chickpea Curry Soup:** Chickpeas, leeks, curry, lemons - **Pork Belly with Vegetables:** Potatoes, butter---### Step 4: Adjusting for Minimum Order- If total is below CHF 99, add liquid soap refill to reach minimum- If still needed, add bread or dark chocolate- Check if you bought MORE than needed - if over CHF200, remove items- Remove alcoholic products if age verification is needed---### Step 5: Select Delivery Window- Choose delivery window within current week- OK to pay up to CHF2 for window selection- Preferably select a workweek slot---### Step 6: Checkout- Proceed to checkout- Select TWINT as payment method- Complete the order---### Step 7: Output Summary- Final list of items purchased (including substitutions)- Total cost- Chosen delivery time"""agent = Agent(task=task, llm=ChatOpenAI(model='gpt-4.1-mini'))async def main(): await agent.run() input('Press Enter to close the browser...')if __name__ == '__main__': asyncio.run(main())
Security: Never store real payment information in scripts. Use test accounts or authentication profiles.
task = """Complete checkout on example-store.com:Shipping Information:- Name: John Doe- Address: 123 Main St- City: San Francisco- State: CA- ZIP: 94102Delivery:- Select standard shipping (5-7 days)Review:- Verify order total- Check all items are correct- Apply any available couponsDO NOT submit payment - stop at payment review page."""agent = Agent( task=task, llm=ChatBrowserUse(), sensitive_data={'address': '123 Main St'} # Protect sensitive data)
task = """On Amazon.com:1. Search for "laptop"2. Filter by: - Price: $500-$1000 - Brand: Dell or HP - Rating: 4 stars and above3. Sort by: Customer reviews (highest first)4. Show me the top 3 results with: - Name - Price - Rating - Key features"""
task = """Go to BestBuy.com and:1. Navigate to "Deals" section2. Filter by "Today's Deals"3. Find electronics with at least 30% off4. Sort by highest discount5. Extract top 5 deals with: - Product name - Original price - Sale price - Discount percentage - Deal expiration time"""
task = """Go to my Amazon account subscriptions page:1. List all active subscriptions2. For each subscription show: - Product name - Delivery frequency - Next delivery date - Price3. Pause the coffee subscription4. Change dog food delivery from monthly to bi-weekly"""