Skip to content

Commit f9ed826

Browse files
fix: merge .percy.yml config options with snapshot options for serializeDOM
Config options from .percy.yml (like widths, minHeight, enableJavaScript, etc.) were not being passed to PercyDOM.serialize(). Only per-snapshot options were used. Now merges both, with per-snapshot options taking priority. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4bda7d4 commit f9ed826

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/main/java/io/percy/selenium/Percy.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,18 @@ public JSONObject snapshot(String name, Map<String, Object> options) {
353353

354354
Object domSnapshot = null;
355355

356+
// Merge .percy.yml config options with snapshot options (snapshot options take priority)
357+
Map<String, Object> mergedOptions = new HashMap<>();
358+
if (cliConfig != null && cliConfig.has("snapshot") && !cliConfig.isNull("snapshot")) {
359+
JSONObject snapshotConfig = cliConfig.getJSONObject("snapshot");
360+
for (String key : snapshotConfig.keySet()) {
361+
mergedOptions.put(key, snapshotConfig.get(key));
362+
}
363+
}
364+
if (options != null) {
365+
mergedOptions.putAll(options);
366+
}
367+
356368
try {
357369
JavascriptExecutor jse = (JavascriptExecutor) driver;
358370
jse.executeScript(fetchPercyDOM());
@@ -362,10 +374,10 @@ public JSONObject snapshot(String name, Map<String, Object> options) {
362374
} catch(Exception e) {
363375
log("Cookie collection failed " + e.getMessage(), "debug");
364376
}
365-
if (isCaptureResponsiveDOM(options)) {
366-
domSnapshot = captureResponsiveDom(driver, cookies, options);
377+
if (isCaptureResponsiveDOM(mergedOptions)) {
378+
domSnapshot = captureResponsiveDom(driver, cookies, mergedOptions);
367379
} else {
368-
domSnapshot = getSerializedDOM(jse, cookies, options);
380+
domSnapshot = getSerializedDOM(jse, cookies, mergedOptions);
369381
}
370382
} catch (WebDriverException e) {
371383
// For some reason, the execution in the browser failed.

0 commit comments

Comments
 (0)