Skip to content

Add Cucumber step definitions for Percy visual testing#34

Open
neha-sanse wants to merge 4 commits intomainfrom
feature/cucumber-support
Open

Add Cucumber step definitions for Percy visual testing#34
neha-sanse wants to merge 4 commits intomainfrom
feature/cucumber-support

Conversation

@neha-sanse
Copy link
Copy Markdown

Summary

  • Add PercySteps class in io.percy.playwright.cucumber package with Gherkin step definitions for Percy Snapshot and Create Percy Region
  • Cucumber dependency is provided scope -- users bring their own Cucumber version
  • Unit tests for all step definitions

Cucumber Steps

Snapshot (DOM)

When I take a Percy snapshot named "Homepage"
When I take a Percy snapshot named "Responsive" with widths "375,768,1280"
When I take a Percy snapshot named "Styled" with Percy CSS "h1 { color: red; }"
When I take a Percy snapshot named "Scoped" with scope ".todoapp"
When I take a Percy snapshot named "Layout" with layout mode
When I take a Percy snapshot named "Tagged" with labels "smoke,regression"

Regions

Given I create a Percy ignore region with CSS selector ".ad-banner"
Given I create a Percy ignore region with XPath "//header"
Given I create a Percy ignore region with bounding box 0, 0, 600, 80
Given I create a Percy consider region with CSS selector ".content"
Given I create a Percy consider region with CSS selector ".content" and diff sensitivity 3
Given I create a Percy intelliignore region with CSS selector ".dynamic"

Setup

@Before
public void setUp() {
    playwright = Playwright.create();
    browser = playwright.chromium().launch();
    page = browser.newPage();
    PercySteps.setPage(page);
}

@After
public void tearDown() {
    browser.close();
    playwright.close();
    PercySteps.reset();
}

Test plan

  • Unit tests pass for all step definitions
  • Compile with Cucumber 7.x provided dependency
  • Verify steps work in a Cucumber feature file with Percy exec

Note: No Percy Screenshot (Automate) steps -- Automate is Selenium/WebDriver only.

🤖 Generated with Claude Code

Add PercySteps class providing Gherkin step definitions for:
- Percy Snapshot (DOM): widths, min height, percy CSS, scope, layout mode,
  JavaScript, labels, test case, responsive capture
- Create Percy Region: ignore/consider/intelliignore by CSS, XPath,
  bounding box, with diff sensitivity and padding
- Data table support for arbitrary options

Cucumber dependency is provided scope - users bring their own version.
Includes unit tests for all step definitions.

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 22, 2026 14:31
neha-sanse and others added 3 commits April 23, 2026 10:19
- Add setClientInfo/setEnvironmentInfo to Percy and Environment classes
- PercySteps sets client to "percy-cucumber-java-playwright/<version>"
  and environment to "cucumber-java/<version>; playwright-java"
- Add Percy.getSdkVersion() public static method

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add screenshot step definitions for BrowserStack Automate:
- I take a Percy screenshot named {string}
- I take a Percy screenshot named {string} with regions
- I take a Percy screenshot named {string} with options:

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add ignore/consider region with padding
- Add consider region with XPath (+ diff sensitivity)
- Add intelliignore region with XPath
- Add snapshot steps: Shadow DOM disabled, responsive capture, sync
- Add scopeOptions and sync parsing in buildOptions helper

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