Skip to content

Add Robot Framework support via PercyLibrary#220

Open
neha-sanse wants to merge 12 commits intomasterfrom
feature/robot-framework-support
Open

Add Robot Framework support via PercyLibrary#220
neha-sanse wants to merge 12 commits intomasterfrom
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 directly into percy-selenium-python. No separate SDK needed — users install robotframework and robotframework-seleniumlibrary alongside percy-selenium and get Robot keywords automatically.

What's added

  • percy/robot_library.py — Robot Framework library with keywords
  • tests/test_robot_library.py — 17 tests covering all functionality
  • Graceful import in percy/__init__.py — no impact when robotframework is not installed

Keywords

  • Percy Snapshot — capture DOM snapshots with all options (widths, percy_css, scope, labels, regions, responsive capture, layout mode, etc.)
  • Percy Screenshot — BrowserStack Automate support with element region handling
  • Create Percy Region — build ignore/consider region definitions (CSS, XPath, bounding box, padding, algorithm config)
  • Percy Is Running — check Percy CLI availability

Key design decisions

  • import robot wrapped in try/except — existing percy-selenium behavior is unchanged when robotframework is not installed
  • PercyLibrary delegates to existing percy_snapshot() and percy_automate_screenshot() — no code duplication
  • All keyword arguments are parsed from Robot string types (comma-separated, JSON, booleans) into Python types before forwarding
  • When robotframework is not installed, a stub PercyLibrary class raises ImportError with a clear message

Usage

*** Settings ***
Library    SeleniumLibrary
Library    percy.robot_library.PercyLibrary

*** Test Cases ***
Homepage Visual Test
    Open Browser    https://example.com    chrome
    Percy Snapshot    Homepage
    Percy Snapshot    Responsive    widths=375,768,1280
    Percy Snapshot    Tagged    labels=regression,v2
    Close Browser
percy exec -- robot tests/

Test plan

References

🤖 Generated with Claude Code

Adds native Robot Framework keywords for Percy visual testing:
- Percy Snapshot — capture DOM snapshots with all options (widths,
  percy_css, scope, labels, regions, responsive capture, etc.)
- Percy Screenshot — BrowserStack Automate support
- Create Percy Region — build ignore/consider region definitions
- Percy Is Running — check Percy CLI availability

Robot Framework import is wrapped in try/except so the existing
percy-selenium package works unchanged when robotframework is not
installed. When it is installed, PercyLibrary becomes available as
a Robot library that delegates to the existing percy_snapshot() and
percy_automate_screenshot() functions.

Usage:
  Library    percy.robot_library.PercyLibrary

17 new tests covering parse helpers, keyword dispatch, and graceful import.

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 13:42
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
neha-sanse and others added 10 commits April 21, 2026 19:37
28 end-to-end Robot tests 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, responsive capture, 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>
…-error in pylint

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

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>
…schema

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

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

When Robot Framework tests use percy.robot_library.PercyLibrary, the
snapshot module's CLIENT_INFO was hardcoded to percy-selenium-python,
causing Percy builds to display "selenium" in the Environment field.

Override the snapshot module's CLIENT_INFO and ENV_INFO when PercyLibrary
is instantiated so the Percy CLI sends the correct wrapper identity
(percy-robotframework-selenium) to the Percy API. The override only
applies in Robot Framework context — plain Selenium users are unaffected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move selenium import before percy imports to fix wrong-import-order.
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