Skip to content

Add Robot Framework support via PercyLibrary (Browser library)#138

Open
neha-sanse wants to merge 9 commits intomainfrom
feature/robot-framework-support
Open

Add Robot Framework support via PercyLibrary (Browser library)#138
neha-sanse wants to merge 9 commits intomainfrom
feature/robot-framework-support

Conversation

@neha-sanse
Copy link
Copy Markdown

@neha-sanse neha-sanse commented Apr 21, 2026

Summary

Adds native Robot Framework keywords for Percy visual testing using the Browser library (robotframework-browser / Playwright backend). Mirrors the same PR on percy-selenium-python (#220) for the Selenium backend.

What's added

  • percy/robot_library.py — Robot Framework library with keywords and Browser library adapter
  • tests/test_robot_library.py — 12 tests
  • Graceful import in percy/__init__.py
  • development.txt — added robotframework and robotframework-browser

Keywords

  • Percy Snapshot — capture DOM snapshots with all options
  • Create Percy Region — build ignore/consider region definitions
  • Percy Is Running — check Percy CLI availability

Key design decisions

  • import robot wrapped in try/except — zero impact when robotframework is not installed
  • Lazy imports for percy.screenshot — playwright only loaded when keywords are called, not at import time
  • _BrowserLibraryPageAdapter bridges Browser library keywords to the Playwright page interface that percy_snapshot() expects
  • When robotframework is not installed, a stub class raises ImportError with clear message

Usage

*** Settings ***
Library    Browser
Library    percy.robot_library.PercyLibrary

*** Test Cases ***
Homepage Visual Test
    New Browser    chromium    headless=true
    New Page    https://example.com
    Percy Snapshot    Homepage
    Percy Snapshot    Responsive    widths=375,768,1280
    Close Browser
percy exec -- robot tests/

Test plan

  • 12 new tests passing (parse helpers, keyword dispatch, lazy imports)
  • Mocks playwright at module level so tests run without playwright installed
  • CI pipeline passes

Related

🤖 Generated with Claude Code

Adds native Robot Framework keywords for Percy visual testing using
the Browser library (robotframework-browser / Playwright):
- Percy Snapshot — capture DOM snapshots with all options
- Create Percy Region — build ignore/consider region definitions
- Percy Is Running — check Percy CLI availability

Robot Framework and Playwright imports are wrapped for graceful
degradation — existing percy-playwright behavior is unchanged when
robotframework is not installed. Uses lazy imports so playwright is
only loaded when keywords are actually called.

Includes _BrowserLibraryPageAdapter that bridges Browser library
keywords to the Playwright page interface percy_snapshot() expects.

12 new tests covering parse helpers, keyword dispatch, and lazy imports.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@neha-sanse neha-sanse requested a review from a team as a code owner April 21, 2026 14:03
neha-sanse and others added 8 commits April 21, 2026 19:39
23 end-to-end Robot tests using Browser library (Playwright) covering
all Percy keywords: basic snapshots, responsive widths, min height,
Percy CSS, scoped snapshots, JS/layout/shadow DOM, labels, test case
metadata, ignore/consider/intelliignore regions, all options combined,
and utility keywords.

Run with: percy exec -- robot tests/test_robot_integration.robot

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ror, exclude robot_library from coverage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…port

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…cess, import-outside-toplevel

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…cy_snapshot

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Show full workflow for using Create Percy Region with Percy Snapshot,
including multiple regions, padding, and bounding box examples.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Shorten docstring examples to stay within 100-char limit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant