diff --git a/src/main/java/io/percy/playwright/Environment.java b/src/main/java/io/percy/playwright/Environment.java
index 552373a..cfede57 100644
--- a/src/main/java/io/percy/playwright/Environment.java
+++ b/src/main/java/io/percy/playwright/Environment.java
@@ -9,12 +9,33 @@ class Environment {
private final static String SDK_VERSION = "1.0.2";
private final static String SDK_NAME = "percy-playwright-java";
+ private String clientInfoOverride;
+ private String environmentInfoOverride;
+
public String getClientInfo() {
+ if (clientInfoOverride != null) {
+ return clientInfoOverride;
+ }
return SDK_NAME + "/" + SDK_VERSION;
}
public String getEnvironmentInfo() {
+ if (environmentInfoOverride != null) {
+ return environmentInfoOverride;
+ }
String playwrightVersion = Playwright.class.getPackage().getImplementationVersion();
return String.format("playwright-java; %s", playwrightVersion);
}
+
+ void setClientInfo(String clientInfo) {
+ this.clientInfoOverride = clientInfo;
+ }
+
+ void setEnvironmentInfo(String environmentInfo) {
+ this.environmentInfoOverride = environmentInfo;
+ }
+
+ public static String getSdkVersion() {
+ return SDK_VERSION;
+ }
}
diff --git a/src/main/java/io/percy/playwright/Percy.java b/src/main/java/io/percy/playwright/Percy.java
index 2f2224e..ff8b93e 100644
--- a/src/main/java/io/percy/playwright/Percy.java
+++ b/src/main/java/io/percy/playwright/Percy.java
@@ -73,6 +73,22 @@ public Percy(Page page) {
this.env = new Environment();
}
+ /**
+ * Override the client info reported to Percy.
+ * Used by framework wrappers (e.g., Cucumber) to identify themselves.
+ */
+ public void setClientInfo(String clientInfo, String environmentInfo) {
+ this.env.setClientInfo(clientInfo);
+ this.env.setEnvironmentInfo(environmentInfo);
+ }
+
+ /**
+ * Get the SDK version string.
+ */
+ public static String getSdkVersion() {
+ return Environment.getSdkVersion();
+ }
+
/**
* Creates a region configuration based on the provided parameters.
*
diff --git a/src/main/java/io/percy/playwright/cucumber/PercySteps.java b/src/main/java/io/percy/playwright/cucumber/PercySteps.java
new file mode 100644
index 0000000..db59ee6
--- /dev/null
+++ b/src/main/java/io/percy/playwright/cucumber/PercySteps.java
@@ -0,0 +1,441 @@
+package io.percy.playwright.cucumber;
+
+import io.cucumber.java.en.Given;
+import io.cucumber.java.en.When;
+import io.cucumber.java.en.Then;
+import io.percy.playwright.Percy;
+
+import com.microsoft.playwright.Page;
+
+import java.util.*;
+
+/**
+ * Cucumber step definitions for Percy visual testing with Playwright.
+ *
+ * Provides Gherkin steps to capture Percy snapshots and define
+ * ignore/consider regions from Cucumber feature files.
+ *
+ * Usage in feature files:
+ *
+ * Feature: Visual Testing
+ * Scenario: Homepage visual test
+ * Given I have a Percy instance
+ * When I take a Percy snapshot named "Homepage"
+ *
+ * Scenario: Snapshot with options
+ * Given I have a Percy instance
+ * When I take a Percy snapshot named "Responsive" with widths "375,768,1280"
+ *
+ * Scenario: Ignore region
+ * Given I have a Percy instance
+ * And I create a Percy ignore region with CSS selector ".ad-banner"
+ * When I take a Percy snapshot named "No Ads" with regions
+ *
+ *
+ * Setup in step definition glue:
+ *
+ * public class Hooks {
+ * private static Playwright playwright;
+ * private static Browser browser;
+ * private static Page page;
+ *
+ * {@literal @}Before
+ * public void setUp() {
+ * playwright = Playwright.create();
+ * browser = playwright.chromium().launch();
+ * page = browser.newPage();
+ * PercySteps.setPage(page);
+ * }
+ *
+ * {@literal @}After
+ * public void tearDown() {
+ * if (browser != null) browser.close();
+ * if (playwright != null) playwright.close();
+ * PercySteps.reset();
+ * }
+ * }
+ *
+ */
+public class PercySteps {
+
+ private static Page page;
+ private static Percy percy;
+ private static List