Skip to content

Latest commit

 

History

History
91 lines (73 loc) · 5.07 KB

AGENTS.md

File metadata and controls

91 lines (73 loc) · 5.07 KB

robotframework-browser

A Robot Framework library on top of Playwright. Python keywords (Browser/) call a Node.js Playwright wrapper (node/playwright-wrapper/) over gRPC (protobuf/playwright.proto), so a keyword change usually touches all three. Supports Python 3.11+, Node 22/24/26 and Robot Framework 7.1.1+. The Robot Framework floor lives in pyproject.toml and in the rf-version of the CI matrix; change both together.

Where things are

  • Browser/browser.py: Browser(DynamicCore), the library class. It owns global and scoped state (scope_stack).
  • Browser/keywords/: one keyword class per feature area, each extending LibraryComponent (Browser/base/librarycomponent.py).
  • Browser/assertion_engine.py: @with_assertion_polling. The assertion helpers (verify_assertion and friends) come from the assertionengine package.
  • node/playwright-wrapper/grpc-service.ts: one handler per rpc. playwright-state.ts owns the browser, context and page lifecycle. playwright-invoke.ts has findLocator, which resolves selectors, strict mode and frames for almost every keyword.
  • node/dynamic-test-app/: the Test App that the acceptance tests drive.
  • tools/ci_failures/: maintainers' analysis of CI failures.

CONTEXT-MAP.md lists the domain contexts and their CONTEXT.md vocabularies, and docs/adr/ holds the decisions. Read the relevant ones before changing how a keyword call reaches its body (the Robot Framework path and the Python path differ on purpose), the Test App logging, or tools/ci_failures.

Generated files

These are gitignored and regenerated; edit their sources instead.

Files Regenerated by
Browser/generated/, node/playwright-wrapper/generated/ inv protobuf
Browser/wrapper/, Browser/browser.pyi, mypy_stub/ inv node-build
node/dynamic-test-app/dist/ inv create-test-app

Build and test

Set up once with python bootstrap.py, activate .venv, then inv build. inv build installs the Python dependencies on every run, but the Node dependencies and Playwright browsers only when package-lock.json changed since the last install. inv deps --force reinstalls them, for example after a broken browser install. PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD skips the browsers.

After a change to the proto, the TypeScript wrapper, or a keyword signature or docstring, run inv node-build. It regenerates protobuf, the wrapper and browser.pyi. inv atest and inv utest test the last build of the wrapper and never rebuild it. inv atest does rebuild the Test App.

  • inv utest: pytest. Importing Browser needs the generated protobuf. test_python_usage.py, test_screenshot.py, test_secrets.py and test_shared_playwright_port.py launch Node and a real browser. Tests that need the built Test App take the session-scoped test_app_url fixture (utest/conftest.py); it starts the app through atest/library/test_app_server.py, the same start-and-retry code the acceptance tests use. test_close_deadline.py and test_python_arguments.py start Node without a browser. One file: inv utest --suite utest/test_x.py.
  • inv utest-node: Jest, in node/playwright-wrapper/__tests__/.
  • inv atest --suite <name> (or --test, --include): pabot, with one Node process shared by every worker. Results land in atest/output/; inv atest-failed reruns the failures.
  • inv lint: lint-python (ruff format and check, mypy; --fix fixes), lint-node (prettier, eslint, tsc --noEmit) and lint-robot (robocop format). Locally lint-node and lint-robot rewrite files; in CI they only check.
  • Coverage: inv --help atest-coverage.

CI (.github/workflows/on-push.yml) is the only gate; there are no git hooks.

Rules

  • A new keyword needs a need. The keyword count stays low on purpose. First try extending an existing keyword, a better assertion, or one higher-level keyword that combines Playwright calls. A new keyword needs Playwright functionality that can only be exposed as a keyword, or a user need that is generally useful. State that plugins or test helpers need goes on an internal Browser property. The change-keyword skill walks through any keyword change.
  • Keyword docstrings are the documentation. They explain intent, what each argument does, and show examples. Code and tests carry minimal comments; names explain them.
  • Keyword annotations stay narrow (button: MouseButton). Python callers get argument conversion instead; widened types belong only in the generated browser.pyi (ADR 0006).
  • State flows from Browser. LibraryComponent delegates to typed properties on Browser (ADR 0009).
  • Plugins: atest/test/09_Plugins/ExamplePlugin.py is the worked example CI runs. User docs: https://robotframework-browser.org/docs/extending/python-plugins

Versions and releases

Browser/version.py is the source; inv version <VERSION> writes it to every other file. The release steps are in CONTRIBUTING.md.

Skills

Project skills are in .claude/skills/, one folder each with a SKILL.md. Load the one whose description matches the task.