Skip to content

Add Cucumber step definitions for Percy visual testing#309

Open
neha-sanse wants to merge 3 commits intomasterfrom
feature/cucumber-support
Open

Add Cucumber step definitions for Percy visual testing#309
neha-sanse wants to merge 3 commits intomasterfrom
feature/cucumber-support

Conversation

@neha-sanse
Copy link
Copy Markdown

Summary

  • Add PercySteps class in io.percy.selenium.cucumber package with Gherkin step definitions for Percy Snapshot, Screenshot (Automate), 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"

Screenshot (Automate)

When I take a Percy screenshot named "Login Page"
When I take a Percy screenshot named "Cart" with regions

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() {
    driver = new ChromeDriver();
    PercySteps.setDriver(driver);
}

@After
public void tearDown() {
    driver.quit();
    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

🤖 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
- Percy Screenshot (Automate): with options and regions
- 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 2 commits April 23, 2026 10:17
- Add setClientInfo/setEnvironmentInfo to Percy and Environment classes
- PercySteps sets client to "percy-cucumber-java-selenium/<version>"
  and environment to "cucumber-java/<version>; selenium-java"
- Add Percy.getSdkVersion() public static method

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