πŸ“š Step-by-Step Tutorial Intermediate Level ⏱️ 60 minutes

Advanced Browser Automation

Master complex browser automation - handle JavaScript, forms, authentication, and dynamic content

🎯
Hands-on
πŸ’»
Code Examples
πŸ“Š
Real Projects
βœ…
Best Practices
βœ“ Updated: March 2025
βœ“ Beginner Friendly
βœ“ Free Forever
60 minutes read 180 sec read

Advanced Browser Automation

Master complex browser operations with OpenClaw - handle authentication, forms, dynamic content, and more.

🎯 What You’ll Learn

Advanced browser automation techniques:

  • Handle authentication and sessions
  • Fill and submit complex forms
  • Work with SPAs (Single Page Applications)
  • Handle infinite scroll and lazy loading
  • Use browser DevTools for debugging
  • Screenshot and visual verification

πŸ“‹ Prerequisites

  • βœ… Completed Your First Web Scraper
  • βœ… Understanding of web technologies
  • βœ… OpenClaw Gateway running

🌐 Step 1: Authentication & Sessions (10 minutes)

Login Automation

Go to https://example.com/login
Fill in the username field with "[email protected]"
Fill in the password field with "mypassword"
Click the login button
Wait for the dashboard to load

⚠️ Security: Never hardcode credentials! Use environment variables or secure storage.

Session Management

Log into https://example.com
Save the session
Navigate to https://example.com/profile
Extract my profile information
Then navigate to https://example.com/settings
Extract my preferences

Handling MFA

Go to https://secure-site.com/login
Enter username and password
When prompted for 2FA code:
- Check my email for the code
- Extract the code from the email
- Enter it on the site
- Continue to dashboard

πŸ“ Step 2: Form Automation (8 minutes)

Multi-Step Forms

Go to https://registration.example.com
Fill in step 1:
  - Name: "John Doe"
  - Email: "[email protected]"
  - Phone: "1234567890"
Click "Next"
Fill in step 2:
  - Address: "123 Main St"
  - City: "New York"
  - ZIP: "10001"
Click "Next"
Fill in step 3:
  - Payment method: "Credit Card"
  - Card number: "4111111111111111" (test card)
  - Expiry: "12/25"
Click "Submit"
Go to https://forms.example.com/survey
Select "United States" from the country dropdown
Select "Software Development" from the industry dropdown
Check all boxes that apply:
  - "Remote work"
  - "Flexible hours"
  - "Health insurance"

File Uploads

Go to https://upload.example.com
Click the file upload button
Upload ~/Documents/resume.pdf
Wait for upload to complete
Verify the upload was successful

πŸ”„ Step 3: Dynamic Content (10 minutes)

Infinite Scroll

Go to https://infinite-scroll-site.com
Scroll down to load more content
Keep scrolling until you've loaded 50 items
Extract all items on the page
Save to scraped-items.json

Waiting for Content

Go to https://slow-loading-site.com
Wait for the .main-content element to appear (up to 30 seconds)
Once loaded, extract all article content

SPAs (Single Page Applications)

Go to https://spa-example.com
Wait for the app to initialize
Click on the "Products" tab
Wait for the product list to load
Extract all product information
Click on "Next" button
Wait for next page to load
Extract next 20 products
Continue until we have 100 products

πŸ“Έ Step 4: Screenshots & Visual Verification (7 minutes)

Full Page Screenshots

Go to https://example.com
Take a full page screenshot
Save it to ~/screenshots/example-homepage-full.png

Element Screenshots

Go to https://example.com/products
Take a screenshot of just the .product-list element
Save to ~/screenshots/product-list.png

Visual Regression

Take a screenshot of https://example.com/home
Compare with the saved screenshot at ~/baseline/homepage.png
If there are significant differences:
  - Highlight the changed areas
  - Save to ~/regression-diffs/[date].png
  - Alert me about visual changes

πŸ”§ Step 5: Advanced Interactions (10 minutes)

Hover and Click

Go to https://menu-example.com
Hover over the "Products" menu item
Wait for dropdown to appear
Click on "Enterprise Solutions" in the dropdown
Wait for the page to load

Drag and Drop

Go to https://kanban.example.com
Drag the card "Task 1" from the "To Do" column
Drop it into the "In Progress" column
Wait for the change to be saved

Keyboard Navigation

Go to https://example.com/data
Press Tab to navigate through the table
Press Enter to select rows
Select rows 1, 3, and 5
Press Ctrl+C to copy

🌍 Step 6: Multi-Tab Workflows (8 minutes)

Working with Multiple Tabs

Open https://site1.com in a new tab
Open https://site2.com in another new tab
Extract data from both tabs
Combine the results
Save to combined-data.json

Tab Management

Open the first 10 search results in new tabs
For each tab:
  - Extract the main content
  - Take a screenshot
  - Close the tab
Combine all extracted content
Save to multi-site-scrape.json

🚨 Troubleshooting

Issue: β€œElement not found”

Solution:

Go to https://example.com
Inspect the page and tell me what selectors I should use
Wait for the element to appear
Then try the extraction again

Issue: β€œSite detected automation”

Solution:

Use stealth mode to access https://protected-site.com
Rotate the user agent to look like a regular browser
Add delays between actions to appear human-like

Issue: β€œJavaScript errors”

Solution:

Go to https://problematic-site.com
Capture browser console errors
Report the errors to me
Try to continue despite the errors

Issue: β€œMemory issues”

Solution:

Process in batches:
Open first 10 results
Extract data and save
Close those tabs
Open next 10 results
Continue until done

πŸ’‘ Advanced Examples

Example 1: E-commerce Purchase Bot

Automated purchasing:

1. Go to https://shop.example.com/product/12345
2. Check if price is below $100
3. If yes:
   - Add to cart
   - Go to checkout
   - Fill in shipping details from ~/my-shipping-info.json
   - Select payment method
   - Complete purchase
   - Save order confirmation
   - Send me a summary
4. If no, alert me about price

Example 2: Social Media Automation

Social media management:

1. Log into https://twitter.com
2. Go to my profile
3. Extract my recent tweets
4. For each tweet:
   - Check engagement metrics
   - If low engagement:
     - Delete tweet
     - Log to ~/deleted-tweets.json
5. Post a new tweet from ~/scheduled-tweets/
6. Log the posted tweet

Example 3: Testing Web Applications

Automated testing:

1. Go to https://myapp.example.com/login
2. Test login with valid credentials
3. Verify we're redirected to dashboard
4. Test login with invalid credentials
5. Verify error message appears
6. Run accessibility audit
7. Report all issues to ~/test-results.json

🎯 Best Practices

1. Be Respectful

Add delays between actions
Don't overwhelm servers
Follow robots.txt guidelines

2. Handle Errors Gracefully

If something fails:
- Take a screenshot for debugging
- Log the error
- Try alternative approaches
- Don't crash the entire workflow

3. Use Explicit Wait Conditions

Don't just wait 5 seconds
Wait for specific elements to appear:
"Wait for .data-loaded to appear (max 30s)"

4. Validate Results

After scraping, verify:
- We got the expected number of items
- Data looks reasonable
- No obvious errors in the data

5. Clean Up Resources

After completing tasks:
- Close all open tabs
- Clear browser cache
- Release memory
- Log completion

🎯 What’s Next?


⏱️ Total Time: 60 minutes πŸ“Š Difficulty: Intermediate 🎯 Result: Advanced browser automation workflows

πŸŽ‰

Congratulations!

You've completed this tutorial. Ready for the next challenge?