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(value) Type Text selector value
page.press(selector, key) Keyboard Key press key
page.check(selector) or .check() Check Checkbox selector
page.uncheck(selector) or .uncheck() Uncheck Checkbox selector
page.select_option(selector, value) or .select_option(value) Select Options By selector value value
page.set_input_files(selector, file) or .set_input_files(file) Upload File By Selector selector file
page.hover(selector) or .hover() Hover selector
page.dblclick(selector) or .dblclick() 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(locator).to_be_checked() Get Checkbox State selector == checked
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.7.0.tar.gz (15.7 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.7.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for robotframework_browser_recorder-0.7.0.tar.gz
Algorithm Hash digest
SHA256 57b67b66c982a8bf025f1f0ab7b92b24f290f556a8e80ee10c0969a5fd117654
MD5 c6463d4187f8898069071b5f4a1fcfa0
BLAKE2b-256 48860ca8c6a5a53379dd4958cb82623053e7849848a69788e42c72f5f84f126f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for robotframework_browser_recorder-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b0c563d94817053f9e9d657499cbe119bcebf8927f66f08685a425ce2d98338
MD5 a9a647ec65f89ccb6bbddfc31ce1fbb7
BLAKE2b-256 a25d4b532066c7ffc9e569aadf5d5cdbb49f48dfc8ca874eacc4cc96997ced95

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