Record browser interactions and generate Robot Framework tests using Browser library
Project description
Robot Framework Browser Recorder
A Python package that records browser interactions using Playwright's codegen feature and automatically converts them to Robot Framework test cases using the Browser library.
Features
- 🎥 Record browser interactions using Playwright's powerful codegen tool
- 🤖 Automatic conversion to Robot Framework test syntax
- 🌐 Multi-browser support: Chromium, Firefox, and WebKit
- 🎯 Simple CLI for quick test generation
- 📝 Clean, readable output with simplified selectors (e.g.,
data-test=logininstead of[data-test="login"])
Installation
Prerequisites
- Python 3.8 or higher
- Playwright (installed automatically with the package)
Install the package
pip install robotframework-browser-recorder
Install Playwright browsers
After installing the package, you need to install Playwright browsers:
playwright install # Install all browsers
# OR install specific browsers:
playwright install chromium
playwright install firefox
playwright install webkit
Install Robot Framework Browser library
pip install robotframework-browser
rfbrowser init
Quick Start
Basic Recording
Record browser interactions and generate a Robot Framework test:
rfbrowser-record --url https://example.com
This will:
- Open a browser window with the Playwright inspector (Chromium by default)
- Navigate to the specified URL
- Record all your interactions (clicks, typing, etc.)
- Generate a
recorded_test.robotfile when you close the browser
Run Your Test
After recording, run your test with:
robot recorded_test.robot
Usage
Command Line Interface
rfbrowser-record [OPTIONS]
Options
| Option | Short | Description | Default |
|---|---|---|---|
--url |
-u |
Initial URL to navigate to | None |
--browser |
-b |
Browser to use (chromium, firefox, webkit) | chromium |
--output |
-o |
Output file path | recorded_test.robot |
--test-name |
-n |
Name of the test case | Recorded Test |
--version |
Show version |
Examples
Record with Firefox
rfbrowser-record --browser firefox --url https://example.com
Record with custom output file
rfbrowser-record --url https://example.com --output my_test.robot
Python API
You can also use the recorder programmatically:
from robotframework_browser_recorder import BrowserRecorder
# Create a recorder instance (Chromium by default)
recorder = BrowserRecorder(
output_file="my_test.robot",
test_name="My Custom Test",
url="https://example.com"
)
# Start recording
recorder.record()
# Or use Firefox
recorder_ff = BrowserRecorder(
browser="firefox",
output_file="my_test.robot",
url="https://example.com"
)
recorder_ff.record()
Converting Playwright Code
If you already have Playwright Python code, you can convert it:
from robotframework_browser_recorder import PlaywrightToRobotConverter
playwright_code = """
page.goto("https://example.com")
page.locator("[data-test='login']").click()
page.locator("[data-test='username']").fill("testuser")
page.locator("[data-test='password']").fill("testpass")
page.locator("[data-test='submit']").click()
"""
converter = PlaywrightToRobotConverter()
robot_test = converter.convert(
playwright_code=playwright_code,
test_name="Login Test"
)
print(robot_test)
Supported Actions
The converter supports the following Playwright actions:
| Playwright Action | Robot Framework Keyword |
|---|---|
page.goto(url) |
New Page url |
page.click(selector) or .click() |
Click selector |
page.fill(selector, value) or .fill() |
Type Text selector value |
page.press(selector, key) |
Keyboard Key press key |
page.check(selector) |
Check Checkbox selector |
page.uncheck(selector) |
Uncheck Checkbox selector |
page.select_option(selector, value) |
Select Options By selector value value |
page.hover(selector) |
Hover selector |
page.dblclick(selector) |
Click selector clickCount=2 |
page.screenshot(path=path) |
Take Screenshot path |
page.wait_for_load_state(state) |
Wait For Load State state |
Example Output
After recording interactions on a website, you'll get a clean Robot Framework test:
*** Settings ***
Library Browser
*** Test Cases ***
Login Test
New Browser chromium headless=False
New Context viewport={'width': 1920, 'height': 1080}
New Page https://example.com
Click data-test=nav-sign-in
Type Text data-test=email test@test.nl
Type Text data-test=password SuperSecretPassword!
Click data-test=login-submit
Notice how selectors are simplified:
[data-test="nav-sign-in"]becomesdata-test=nav-sign-in[id="submit"]becomesid=submit
Development
Setup Development Environment
# Clone the repository
git clone https://github.com/yourusername/robotframework-browser-recorder.git
cd robotframework-browser-recorder
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
# Install Playwright
playwright install chromium
Running Tests
pytest tests/
Code Formatting
black robotframework_browser_recorder/
Troubleshooting
Playwright not found
If you get an error about Playwright not being installed:
pip install playwright
playwright install chromium
Browser library not found
Make sure the Robot Framework Browser library is installed:
pip install robotframework-browser
rfbrowser init chromium
Recording produces no output
Make sure you actually perform some interactions in the browser before closing it. The recorder only captures actions like clicks, typing, navigation, etc.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
Apache License 2.0
Related Projects
Acknowledgments
This project builds upon the excellent work of:
- The Robot Framework community
- The Playwright team at Microsoft
- The Browser library maintainers
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file robotframework_browser_recorder-0.1.0.tar.gz.
File metadata
- Download URL: robotframework_browser_recorder-0.1.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c263153aa5f24affcd4078da2a76b34844320fef2b317015ab96a28e92f61c7
|
|
| MD5 |
ca7d70590a70c342c358577814c7b464
|
|
| BLAKE2b-256 |
ae53b643084e5a06dcc6a162b72d8d13c880a1909089d9695a8e7fcdf0fe2269
|
File details
Details for the file robotframework_browser_recorder-0.1.0-py3-none-any.whl.
File metadata
- Download URL: robotframework_browser_recorder-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78aa5f2a566c66e7943e6d5a4dc4dc51dbeeca18d85429378fadc628b7634b1b
|
|
| MD5 |
afde61ea0ae4befb72f377d3b8bf3c76
|
|
| BLAKE2b-256 |
2756816c5fa110cc3719c89934a7d2378d3fe74d729611f22ce49888b32945cd
|