Skip to main content

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=login instead 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:

  1. Open a browser window with the Playwright inspector (Chromium by default)
  2. Navigate to the specified URL
  3. Record all your interactions (clicks, typing, etc.)
  4. Generate a recorded_test.robot file 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

Supported Actions

The converter supports the following Playwright actions:

Interactions

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

Assertions / Verifications

Playwright Assertion Robot Framework Keyword
expect(locator).to_be_visible() Get Element States selector validate visible
expect(locator).to_have_text(text) Get Text selector == text
expect(locator).to_contain_text(text) Get Text selector == text
expect(locator).to_have_value(value) Get Property selector value == value
expect(page).to_have_url(url) Get Url == url
expect(page).to_have_title(title) Get Title == title

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"] becomes data-test=nav-sign-in
  • [id="submit"] becomes id=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

robotframework_browser_recorder-0.2.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robotframework_browser_recorder-0.2.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file robotframework_browser_recorder-0.2.0.tar.gz.

File metadata

File hashes

Hashes for robotframework_browser_recorder-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f7bd32b96400a392571c115084df51fdcc4c3c283416ffdaf2e78a7d37623feb
MD5 4e44dd656ebd69a267d5826a933be1c5
BLAKE2b-256 d64fe9bd2f32a5cda40ac0d4f6dadbc3de1be267dd2ef59233ffbedab59ef6cb

See more details on using hashes here.

File details

Details for the file robotframework_browser_recorder-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_browser_recorder-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 354d2599a2604ddf6a34650dfbe4e0c6601fa0e0c5a0b47155a45c93fe505f54
MD5 0d39b6bd34970866e447b1cb1d06eb48
BLAKE2b-256 89f01a1016166e83506c4edfa3be09d6fa4368f4a05e2f30608ec5f783d3c4f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page