Skip to content

Commit

Permalink
Fix for null pointer errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmay-browserstack committed Sep 28, 2024
1 parent cda5986 commit 2901097
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/io/percy/selenium/Percy.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ private boolean isCaptureResponsiveDOM(Map<String, Object> options) {
}

boolean responsiveSnapshotCaptureCLI = false;
if (eligibleWidths == null) { return false; }
if (CLIconfig.getJSONObject("snapshot").has("responsiveSnapshotCapture")) {
responsiveSnapshotCaptureCLI = CLIconfig.getJSONObject("snapshot").getBoolean("responsiveSnapshotCapture");
}
Expand All @@ -192,7 +193,7 @@ public JSONObject snapshot(String name, Map<String, Object> options) {
if (!isPercyEnabled) { return null; }
if ("automate".equals(sessionType)) { throw new RuntimeException("Invalid function call - snapshot(). Please use screenshot() function while using Percy with Automate. For more information on usage of PercyScreenshot, refer https://www.browserstack.com/docs/percy/integrate/functional-and-visual"); }

List<Map<String, Object>> domSnapshot = new ArrayList<>();
Object domSnapshot = null;

try {
JavascriptExecutor jse = (JavascriptExecutor) driver;
Expand All @@ -206,7 +207,7 @@ public JSONObject snapshot(String name, Map<String, Object> options) {
if (isCaptureResponsiveDOM(options)) {
domSnapshot = captureResponsiveDom(driver, cookies, options);
} else {
domSnapshot.add(getSerializedDOM(jse, cookies, options));
domSnapshot = getSerializedDOM(jse, cookies, options);
}
} catch (WebDriverException e) {
// For some reason, the execution in the browser failed.
Expand Down Expand Up @@ -373,7 +374,7 @@ private String fetchPercyDOM() {
* @param percyCSS Percy specific CSS that is only applied in Percy's browsers
*/
private JSONObject postSnapshot(
List<Map<String, Object>> domSnapshot,
Object domSnapshot,
String name,
String url,
Map<String, Object> options
Expand Down

0 comments on commit 2901097

Please sign in to comment.