Principle:MarketSquare Robotframework browser Node Dependency Initialization
| Knowledge Sources | |
|---|---|
| Domains | Browser_Automation, Dependency_Management |
| Last Updated | 2026-02-12 04:00 GMT |
Overview
Initializing Node.js dependencies in a browser automation framework involves running a deterministic package install followed by downloading platform-specific browser binaries to enable test execution.
Description
After installing the robotframework-browser Python package, the standard installation path requires a second step: initializing the Node.js side of the library. This is handled by the rfbrowser init command, which performs two sequential operations.
Step 1 -- npm ci (Deterministic Dependency Installation):
The command runs npm ci --production --parseable true --progress false inside the Browser/wrapper/ directory. The use of npm ci (rather than npm install) is deliberate:
- It deletes the existing
node_modules/directory before installing - It installs dependencies strictly from
package-lock.json, ensuring byte-for-byte reproducible installations - It refuses to modify
package-lock.json, failing if the lock file is out of sync withpackage.json - The
--productionflag excludes development dependencies, reducing installation size
This step installs the Playwright Node.js module and the gRPC server JavaScript code that the Python library communicates with during test execution.
Step 2 -- Playwright Browser Binary Installation:
Unless the --skip-browsers flag is provided, the init process runs npx --quiet playwright install to download browser binaries. Users can select specific browsers (e.g., rfbrowser init chromium firefox) or install all default browsers.
PLAYWRIGHT_BROWSERS_PATH Environment Variable:
This environment variable controls where Playwright stores its browser binaries:
- When unset,
rfbrowser initsets it to"0", which means Playwright uses its default location relative to the package installation - When set to a custom path, browsers are downloaded to that directory
- This is particularly useful for shared environments where multiple projects use the same browser binaries
Browser Options:
The init command accepts the following browser arguments: chromium, chromium-headless-shell, chromium-tip-of-tree-headless-shell, chrome, chrome-beta, msedge, msedge-beta, msedge-dev, bidi-chromium, firefox, webkit, and webkit-wsl.
Usage
Run rfbrowser init in the following scenarios:
- After first installation:
pip install robotframework-browserthenrfbrowser init - After upgrading:
pip install -U robotframework-browserthenrfbrowser clean-nodethenrfbrowser init - In CI environments: Use
--with-depsto automatically install system-level dependencies that browsers require (fonts, shared libraries) - When only specific browsers are needed:
rfbrowser init chromiumto minimize download size - When managing browsers separately:
rfbrowser init --skip-browsersto install only Node.js dependencies
Theoretical Basis
The initialization process follows this logic:
FUNCTION rfbrowser_init(skip_browser_install, silent_mode, with_deps, browser):
1. Verify that package.json exists in INSTALLATION_DIR (Browser/wrapper/)
2. Verify write permissions to INSTALLATION_DIR
3. Verify that npm is available in PATH
4. IF skip_browser_install:
Set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1"
ELSE IF PLAYWRIGHT_BROWSERS_PATH not set:
Set PLAYWRIGHT_BROWSERS_PATH = "0"
5. Run: npm ci --production --parseable true --progress false
Working directory: Browser/wrapper/
Wait for completion; raise error if exit code != 0
6. IF NOT skip_browser_install:
Build command: "npx --quiet playwright install"
IF specific browsers requested:
Append browser names to command
IF with_deps:
Append "--with-deps" to command
Run the command; raise error if exit code != 0
7. Log "rfbrowser init completed"