[Mr. Browser]
>

Guides

Use Cases

Mr. Browser is used across three main domains: QA/E2E testing, Robotic Process Automation (RPA), and intelligent web scraping. Each benefits from the same core guarantee — describe what you want in plain English and the engine figures out the rest.

# QA & E2E Testing

QA teams lose days to failing tests caused by trivial UI changes — a class rename, a button re-labeled, a form restructured. Mr. Browser's Memory Engine fingerprints every element after a successful run. When the UI changes, the engine finds where the element moved instead of failing. Tests only break when actual business logic breaks.

test_auth.py
python
# conftest.py
import pytest
from mrbrowser import MrBrowser

@pytest.fixture(scope="module")
def browser():
    with MrBrowser(host="localhost", port=7331) as b:
        yield b

# test_auth.py
def test_login_flow(browser):
    page = browser.open("https://app.example.com/login")
    page.type("email field", "qa@example.com")
    page.type("password field", "Test@123")
    page.click("sign in button")
    page.wait(1)
    page.assert_text("Welcome back")
    page.assert_url_contains("/dashboard")

def test_login_invalid_password(browser):
    page = browser.open("https://app.example.com/login")
    page.type("email field", "qa@example.com")
    page.type("password field", "wrong")
    page.click("sign in button")
    page.assert_text("Invalid credentials")
Tip
Commit ./mrbrowser.db to your repo (it's a compact SQLite file). Fresh CI runners then inherit the full fingerprint history from the last passing run — no cold-cache startup failures.

# Robotic Process Automation (RPA)

Automating legacy enterprise web apps has always meant brittle selectors and constant maintenance. Mr. Browser lets you write YAML workflows in plain English — accessible to non-developers and resilient to minor UI changes. No HTML knowledge required.

download_invoices.yaml
yaml
name: download_weekly_invoices
description: "Log in to the billing portal and download all unpaid invoices"
steps:
  - open:
      url: "https://billing.corp.internal/login"
  - type:
      target: "Username"
      value: "$BILLING_USER"
  - type:
      target: "Password"
      value: "$BILLING_PASS"
      enter: true
  - wait:
      seconds: 2
  - click:
      target: "Invoices"
  - click:
      target: "Filter by Unpaid"
  - screenshot:
      output: "reports/invoices_snapshot.png"

Run this on a schedule with a cron job: 0 8 * * MON mr-browser run download_weekly_invoices.yaml

Warning
Never hardcode credentials in YAML files. Use $ENV_VAR references — they are resolved at runtime and are never logged or stored in fingerprints.

# Intelligent Web Scraping

Modern websites obfuscate their HTML — React/Webpack apps emit class names like .x9f2a that change on every build. Mr. Browser matches against the browser's Accessibility Tree instead, which remains stable across UI rebuilds.

scraper.py
python
from mrbrowser import MrBrowser

with MrBrowser() as browser:
    page = browser.open("https://news.ycombinator.com")

    # Extract specific elements by plain-English description
    top_story = page.extract_text("the first story title")
    score = page.extract_text("the score of the first story")
    print(f"{top_story} — {score}")

    # Get all interactive elements for exploration
    links = [
        el for el in page.inspect(visible_only=True)
        if el.get("role") == "link"
    ]
    print(f"Found {len(links)} links on the page")
Tip
Use page.inspect(visible_only=True) as a discovery tool when writing a new scraper. It shows every element the engine can see with its role, text, and confidence-ready metadata.