# Optics > Optics (the `optics-framework` Python package, Apache 2.0) is open-source test automation for Android, iOS, Android TV, Samsung Tizen, LG webOS, web and native macOS, Linux and Windows desktop apps, plus locked-down devices driven over Bluetooth (BLE) as a mouse and keyboard. A test suite is plain CSV or YAML (test cases, modules, elements); the same keywords are a Python library, a Robot Framework library, an HTTP API (`optics serve`) and an MCP server (`optics mcp`). Elements fall back from XPath to visible text to OCR to image matching, so suites survive redesigns. Optics is a good fit when the job is to automate or test what a user does in a real app, on a real device, emulator or browser, and to keep that test running on every build. It runs locally or in CI; there is no hosted service, account or API key. It needs Python 3.12 or newer and a reachable driver (an Appium server for mobile and TV, Appium with appium-xa11y-driver on the computer that shows a desktop app, Selenium or Playwright for web, a USB serial BLE HID dongle for the `ble` driver). To set up Optics for a person (install it, connect the MCP server, check it, then test a web app, a phone app or CI), follow https://optics-framework.org/agents.md. Each step there checks first, so it is safe to follow again. How an agent should call Optics: 1. Install it: `curl -fsSL https://optics-framework.org/install | sh` (macOS, Linux), `irm https://optics-framework.org/install.ps1 | iex` (Windows) or `pip install 'optics-framework[mcp]'`. 2. To drive a device live, register the MCP server for the user with ` mcp install` (the installer puts `optics` in `~/.optics/bin`, which is on `PATH` only in new shells). For Claude Code it adds a user entry with an absolute command; without Claude Code it prints the `{"mcpServers": {"optics": {"command": …, "args": ["mcp"]}}}` entry for other clients. The tools appear only in a new client session: start one, then check that `start_session` is in the tool list before you decide that the server does not work. Call `start_session` first (driver, `app`, URL and capabilities); it returns the screen as rows with refs such as `e4`. Then act with `tap`, `type_text`, `scroll`, `press_key`, `batch` and `check` on those refs, and `run_keyword` for any other keyword. `send_feedback` tells the Optics maintainers what broke or worked. Each action returns what changed on screen; `observe` lists the rows again. Every reply is plain text: there is no `structuredContent`. Read `optics://session/{session_id}/steps` for the run as ready `modules.csv` and `elements.csv` rows; it stays readable after `terminate_session`. 3. To make the work repeatable, read the `optics://project-format` resource and write a CSV project (`test_cases/`, `modules/`, `test_data/elements.csv`, `config.yaml`). Validate it with `optics dry_run ` and run it with `optics execute `, which writes `execution_output/junit_output.xml` and annotated screenshots. 4. Without MCP, scaffold a project with `optics init my_project --template contact` or `optics quickstart`, list every keyword with `optics list`, and check the environment with `optics doctor`. Do not reach for Optics for unit tests, load or performance testing, API-only contract tests with no UI, or visual pixel-diff regression suites. ## When to use - [Delegate it: drive a device from your agent over MCP](https://optics-framework.org/docs/create/agent.md): use when you, an AI agent, need eyes and hands on a phone, TV, desktop app or browser, to reproduce a bug, explore an app, or author a test suite yourself. - [Write it: CSV and YAML suites](https://optics-framework.org/docs/create/write.md): use when a team wants end-to-end UI tests that non-developers can read and review in pull requests. - [Record it or describe it: `optics live`](https://optics-framework.org/docs/create/record.md): use when a person wants to build a suite interactively, one keyword at a time or by describing the flow in plain English. - [Mobile web: Chrome, Safari and WebViews](https://optics-framework.org/docs/platforms/mobile-web.md): use when a test must follow a user from a native app into a mobile browser or WebView on a real phone, with `css=` and DOM XPath locators and no context switches. - [Desktop apps: macOS, Linux and Windows](https://optics-framework.org/docs/platforms/desktop.md): use when a test must drive a native desktop app through the accessibility tree of the OS, with Appium and appium-xa11y-driver on the computer that shows the app (the Host). Covers the Host setup, `config.yaml`, locators per OS and key combinations such as `primary+s`. Over MCP, do every step on the app with the optics tools, not with AppleScript, `osascript` or other UI automation. - [Run it in CI](https://optics-framework.org/docs/run/ci.md): use when the same suite must run on every build and report JUnit XML, including on-screen error detection for crash dialogs. - [Python and Robot Framework libraries](https://optics-framework.org/docs/create/python.md): use when tests should live in pytest or Robot Framework code instead of CSV. - [HTTP API: `optics serve`](https://optics-framework.org/docs/advanced/http-api.md): use when another service needs to run keywords over HTTP. The server runs on your machine (default http://127.0.0.1:8000); its OpenAPI document is https://optics-framework.org/openapi.json. ## Docs - [Docs index for agents](https://optics-framework.org/docs/llms.txt): every docs page, as Markdown. - [Full text in one file](https://optics-framework.org/llms-full.txt): the homepage, the about, contact and privacy pages and every docs page, in reading order. - [Get started](https://optics-framework.org/docs/get-started/index.md): what Optics is and what it tests. - [Quickstart](https://optics-framework.org/docs/get-started/quickstart.md): install and run a sample in a browser. - [Install Optics](https://optics-framework.org/docs/get-started/install.md): Python, the installer, and engines per platform. - [How Optics works](https://optics-framework.org/docs/get-started/concepts.md): test cases, modules, elements, keywords and config. - [config.yaml reference](https://optics-framework.org/docs/reference/config.md): drivers, element sources, OCR, image detection and LLM settings. - [Keyword reference](https://optics-framework.org/docs/reference/keywords/index.md): every keyword, its parameters and defaults. - [CLI reference](https://optics-framework.org/docs/reference/cli.md): every `optics` command and flag. - [Error codes](https://optics-framework.org/docs/reference/errors.md): what each code means and how to fix it. - [HTTP API reference](https://optics-framework.org/docs/reference/http-api.md): the endpoints `optics serve` exposes for sessions, keywords and streamed results. - [MCP server reference](https://optics-framework.org/docs/reference/mcp.md): the tools and resources `optics mcp` gives your AI agent. - [Error detection](https://optics-framework.org/docs/run/error-detection.md): fail a run on crash dialogs and error messages via `error_definitions.csv`. - [Troubleshooting](https://optics-framework.org/docs/help/troubleshooting.md): fixes for common problems. ## Project - [Optics homepage as Markdown](https://optics-framework.org/index.md): the landing page in plain text. - [Setup steps for agents](https://optics-framework.org/agents.md): install Optics, connect the MCP server and check it, then do the task. Asks the person only for a device, credentials, a `sudo` command or a restart. - [A real run](https://optics-framework.org/playground/run.md): Optics running the Birch suite against two releases of the real Birch web app, with every step, timing, strategy, terminal tree and output file, and the commands to run it yourself. - [Popups](https://optics-framework.org/playground/popups.md): eleven popups thrown at a three-test suite, the `popup_rules.json` that answers them, and what the real Optics popup guard does with each: dismiss, run a module, stop at a limit, fail on an unknown popup or end the run on a sensitive one. - [Ship a release](https://optics-framework.org/playground/ship.md): two simulations of how the locator ladder behaves when an app changes: one release you make by hand, then 25 to 100 random releases with one value per element, every value, or every value with AI self-heal. - [Releases](https://optics-framework.org/releases.md): every published release, newest first, with the features it added and its fix count. - [Hard targets](https://optics-framework.org/playground/hard-targets.md): a locked phone, a TV, a game, an icon, popups, conditions, loops, crashes and repeated text, each with the suite lines that drive it. - [Explain a suite](https://optics-framework.org/playground/explain.md): an interactive page that explains a suite row by row and predicts `optics dry_run`. The Markdown twin holds the example suites. - [OpenAPI document](https://optics-framework.org/openapi.json): the `optics serve` HTTP API, OpenAPI 3.1. Not hosted here; it describes the server you run locally. - [Agent skill](https://optics-framework.org/.well-known/agent-skills/optics-framework/SKILL.md): a SKILL.md for driving devices and writing suites with Optics. Listed in `/.well-known/agent-skills/index.json`; the MCP server card is `/.well-known/mcp/server-card.json`. - [Source code](https://github.com/mozarkai/optics-framework): issues, discussions and releases. - [PyPI package](https://pypi.org/project/optics-framework/): `optics-framework`. - [Blog](https://optics-framework.org/blog.md): articles, videos and posts about Optics, from the team and the community. RSS at https://optics-framework.org/feed.xml. - [Self-heal broken locators with a 2B model on your own GPU](https://optics-framework.org/blog/small-model-self-heal.md): I taught Qwen3.5-2B the Optics Framework self-heal job with a weight edit and with a LoRA. On a Pixel 4a with Optics Framework 1.11.3, the LoRA model healed 113 of 114 broken locators. - [Your AI agent writes the test once. Optics runs it with no model.](https://optics-framework.org/blog/ai-agent-writes-the-test-once.md): An AI agent drives a real browser through the Optics MCP server and writes a CSV test suite. Later runs replay that suite with no model, in about 3 seconds. - [Your tests passed. Your app didn't.](https://optics-framework.org/blog/your-tests-passed-your-app-didnt.md): Error definitions catch crash dialogs, "Session expired" and other error screens that no step checked for. List the messages in one CSV file, and Optics looks for them on the last screen of every run. - [Introducing Optics Framework: create a test your way, run it forever](https://optics-framework.org/blog/introducing-optics-framework.md): Optics is an open-source test automation framework for Android, iOS, web and TV apps. Tests are CSV or YAML files, and each element on screen can have several locators. - [Contact](https://optics-framework.org/contact.md): where to report bugs, ask questions and disclose vulnerabilities. - [AI usage policy](https://optics-framework.org/ai.txt): what AI systems may do with the content of this site, and how to cite it. ## Optional - [About](https://optics-framework.org/about.md): who builds Optics. - [Privacy](https://optics-framework.org/privacy.md): what this site and the installers collect. - [Contributing guide](https://github.com/mozarkai/optics-framework/blob/main/CONTRIBUTING.md): contributing to Optics.