Skip to content

Commit

Permalink
Make cookie collection fail safe
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmay-browserstack committed Sep 27, 2024
1 parent a1869b6 commit e6006f8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/io/percy/selenium/Percy.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,20 @@ public JSONObject snapshot(String name, Map<String, Object> options) {
try {
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript(fetchPercyDOM());
Set<Cookie> cookies = driver.manage().getCookies();
Set<Cookie> cookies = new HashSet<>();
try {
cookies = driver.manage().getCookies();
} catch(Exception e) {
log("Cookie collection failed " + e.getMessage(), "debug");
}
if (isCaptureResponsiveDOM(options)) {
domSnapshot = captureResponsiveDom(driver, cookies, options);
} else {
domSnapshot.add(getSerializedDOM(jse, cookies, options));
}
} catch (WebDriverException e) {
// For some reason, the execution in the browser failed.
if (PERCY_DEBUG) { log(e.getMessage()); }
log(e.getMessage(), "debug");
}

return postSnapshot(domSnapshot, name, driver.getCurrentUrl(), options);
Expand Down

0 comments on commit e6006f8

Please sign in to comment.