From 4b4ca12c122ed841d5d092036b977ad7813f1461 Mon Sep 17 00:00:00 2001 From: Pawel Tomaszewski Date: Wed, 24 Apr 2024 15:05:12 +0200 Subject: [PATCH 1/5] IRIS-927-align-java-fps-options --- .../com/saucelabs/visual/CheckOptions.java | 1 - .../java/com/saucelabs/visual/VisualApi.java | 25 +++++- .../model/FullPageScreenshotConfig.java | 87 ++++++++++++++++++- 3 files changed, 109 insertions(+), 4 deletions(-) diff --git a/visual-java/src/main/java/com/saucelabs/visual/CheckOptions.java b/visual-java/src/main/java/com/saucelabs/visual/CheckOptions.java index 8fac9c0d..7d5bdb4e 100644 --- a/visual-java/src/main/java/com/saucelabs/visual/CheckOptions.java +++ b/visual-java/src/main/java/com/saucelabs/visual/CheckOptions.java @@ -53,7 +53,6 @@ public CheckOptions( private DiffingOptionsIn diffingOptions; private Boolean captureDom; private String clipSelector; - private FullPageScreenshotConfig fullPageScreenshotConfig; public static class Builder { diff --git a/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java b/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java index cd625ebb..f52a12b9 100644 --- a/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java +++ b/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java @@ -6,6 +6,7 @@ import com.saucelabs.visual.exception.VisualApiException; import com.saucelabs.visual.graphql.*; import com.saucelabs.visual.graphql.type.*; +import com.saucelabs.visual.model.FullPageScreenshotConfig; import com.saucelabs.visual.model.IgnoreRegion; import com.saucelabs.visual.model.VisualRegion; import com.saucelabs.visual.utils.ConsoleColors; @@ -34,6 +35,7 @@ public static class Builder { private String defaultBranchName; private String buildName; private Boolean captureDom; + private FullPageScreenshotConfig fullPageScreenshotConfig; public Builder(RemoteWebDriver driver, String username, String accessKey) { this(driver, username, accessKey, DataCenter.US_WEST_1.endpoint); @@ -75,6 +77,11 @@ public Builder withCaptureDom(Boolean captureDom) { return this; } + public Builder withFullPageScreenshot(FullPageScreenshotConfig fullPageScreenshotConfig) { + this.fullPageScreenshotConfig = fullPageScreenshotConfig; + return this; + } + public VisualApi build() { VisualApi api = new VisualApi( @@ -87,6 +94,9 @@ public VisualApi build() { if (this.captureDom != null) { api.setCaptureDom(this.captureDom); } + if (this.fullPageScreenshotConfig != null) { + api.setFullPageScreenshotConfig(this.fullPageScreenshotConfig); + } return api; } } @@ -98,6 +108,7 @@ public VisualApi build() { private final String sessionId; private final List uploadedDiffIds = new ArrayList<>(); private Boolean captureDom; + private FullPageScreenshotConfig fullPageScreenshotConfig; private String sessionMetadataBlob; /** @@ -188,6 +199,15 @@ public void setCaptureDom(Boolean captureDom) { this.captureDom = captureDom; } + /** + * Enables full page screenshots + * + * @param fullPageScreenshotConfig activation of DOM Capture. + */ + public void setFullPageScreenshotConfig(FullPageScreenshotConfig fullPageScreenshotConfig) { + this.fullPageScreenshotConfig = fullPageScreenshotConfig; + } + private WebdriverSessionInfoQuery.Result webdriverSessionInfo() { WebdriverSessionInfoQuery query = new WebdriverSessionInfoQuery( @@ -358,7 +378,10 @@ public void sauceVisualCheck(String snapshotName, CheckOptions options) { input.setClipSelector(clipSelector); } - input.setFullPageConfig(options.getFullPageScreenshotConfig()); + FullPageScreenshotConfig fullPageScreenshotConfig = Optional.ofNullable(options.getFullPageScreenshotConfig()).orElse(this.fullPageScreenshotConfig); + if (fullPageScreenshotConfig != null) { + input.setFullPageConfig(fullPageScreenshotConfig); + } CreateSnapshotFromWebDriverMutation mutation = new CreateSnapshotFromWebDriverMutation(input); CreateSnapshotFromWebDriverMutation.Data check = diff --git a/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java b/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java index 852ffd3d..8d548892 100644 --- a/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java +++ b/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java @@ -5,33 +5,84 @@ public class FullPageScreenshotConfig { + private int addressBarShadowPadding; private int delayAfterScrollMs; + private Boolean disableCSSAnimation; private List hideAfterFirstScroll; + private Boolean hideScrollBars; + private int toolBarShadowPadding; + private int scrollLimit; - public FullPageScreenshotConfig(int delayAfterScrollMs, List hideAfterFirstScroll) { + public FullPageScreenshotConfig(int addressBarShadowPadding, int delayAfterScrollMs, Boolean disableCSSAnimation, List hideAfterFirstScroll, Boolean hideScrollBars, int toolBarShadowPadding, int scrollLimit) { + this.addressBarShadowPadding = addressBarShadowPadding; this.delayAfterScrollMs = delayAfterScrollMs; + this.disableCSSAnimation = disableCSSAnimation; this.hideAfterFirstScroll = hideAfterFirstScroll; + this.hideScrollBars = hideScrollBars; + this.toolBarShadowPadding = toolBarShadowPadding; + this.scrollLimit = scrollLimit; } public static class Builder { + private int addressBarShadowPadding; private int delayAfterScrollMs; + private Boolean disableCSSAnimation; private List hideAfterFirstScroll; + private Boolean hideScrollBars; + private int toolBarShadowPadding; + private int scrollLimit; + + public Builder withAddressBarShadowPadding(int addressBarShadowPadding) { + this.addressBarShadowPadding = addressBarShadowPadding; + return this; + } public Builder withDelayAfterScrollMs(int delayAfterScrollMs) { this.delayAfterScrollMs = delayAfterScrollMs; return this; } + public Builder withDisableCSSAnimation(Boolean disableCSSAnimation) { + this.disableCSSAnimation = disableCSSAnimation; + return this; + } + public Builder withHideAfterFirstScroll(String... hideAfterFirstScroll) { this.hideAfterFirstScroll = Arrays.asList(hideAfterFirstScroll); return this; } + public Builder withHideScrollBars(Boolean hideScrollBars) { + this.hideScrollBars = hideScrollBars; + return this; + } + + public Builder withToolBarShadowPadding(int toolBarShadowPadding) { + this.toolBarShadowPadding = toolBarShadowPadding; + return this; + } + + public Builder withScrollLimit(int scrollLimit) { + if (scrollLimit > 0 && scrollLimit <= 10) { + this.scrollLimit = scrollLimit; + } else { + this.scrollLimit = 10; + } + + return this; + } + public FullPageScreenshotConfig build() { - return new FullPageScreenshotConfig(delayAfterScrollMs, hideAfterFirstScroll); + return new FullPageScreenshotConfig(addressBarShadowPadding, delayAfterScrollMs, disableCSSAnimation, hideAfterFirstScroll, hideScrollBars, toolBarShadowPadding, scrollLimit); } } + public int getAddressBarShadowPadding() { + return addressBarShadowPadding; + } + public void setAddressBarShadowPadding(int addressBarShadowPadding) { + this.addressBarShadowPadding = addressBarShadowPadding; + } public int getDelayAfterScrollMs() { return delayAfterScrollMs; } @@ -40,6 +91,14 @@ public void setDelayAfterScrollMs(int delayAfterScrollMs) { this.delayAfterScrollMs = delayAfterScrollMs; } + public Boolean getDisableCSSAnimation() { + return disableCSSAnimation; + } + + public void setDisableCSSAnimation(Boolean disableCSSAnimation) { + this.disableCSSAnimation = disableCSSAnimation; + } + public List getHideAfterFirstScroll() { return hideAfterFirstScroll; } @@ -47,4 +106,28 @@ public List getHideAfterFirstScroll() { public void setHideAfterFirstScroll(String... hideAfterFirstScroll) { this.hideAfterFirstScroll = Arrays.asList(hideAfterFirstScroll); } + + public Boolean getHideScrollBars() { + return hideScrollBars; + } + + public void setHideScrollBars(Boolean hideScrollBars) { + this.hideScrollBars = hideScrollBars; + } + + public int getToolBarShadowPadding() { + return toolBarShadowPadding; + } + + public void setToolBarShadowPadding(int toolBarShadowPadding) { + this.toolBarShadowPadding = toolBarShadowPadding; + } + + public int getScrollLimit() { + return scrollLimit; + } + + public void setScrollLimit(int scrollLimit) { + this.scrollLimit = scrollLimit; + } } From f8aa82268136fa3440aaf8a6310c4935291378db Mon Sep 17 00:00:00 2001 From: Pawel Tomaszewski Date: Thu, 25 Apr 2024 09:25:45 +0200 Subject: [PATCH 2/5] add more fps options to test --- visual-java/src/test/java/com/saucelabs/visual/SmokeTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/visual-java/src/test/java/com/saucelabs/visual/SmokeTest.java b/visual-java/src/test/java/com/saucelabs/visual/SmokeTest.java index 31064d4a..10a1d544 100644 --- a/visual-java/src/test/java/com/saucelabs/visual/SmokeTest.java +++ b/visual-java/src/test/java/com/saucelabs/visual/SmokeTest.java @@ -70,6 +70,8 @@ void testFullPageOptions() { CheckOptions options = new CheckOptions(); FullPageScreenshotConfig config = new FullPageScreenshotConfig.Builder() + .withHideScrollBars(false) + .withScrollLimit(2) .withDelayAfterScrollMs(200) .withHideAfterFirstScroll("#searchform") .build(); From 9081c9f1905efe42f49a0b56d4cbfff4c771f5ce Mon Sep 17 00:00:00 2001 From: Pawel Tomaszewski Date: Thu, 25 Apr 2024 11:49:45 +0200 Subject: [PATCH 3/5] comments --- .../main/java/com/saucelabs/visual/VisualApi.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java b/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java index f52a12b9..86918d11 100644 --- a/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java +++ b/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java @@ -95,7 +95,7 @@ public VisualApi build() { api.setCaptureDom(this.captureDom); } if (this.fullPageScreenshotConfig != null) { - api.setFullPageScreenshotConfig(this.fullPageScreenshotConfig); + api.enableFullPageScreenshots(this.fullPageScreenshotConfig); } return api; } @@ -199,12 +199,19 @@ public void setCaptureDom(Boolean captureDom) { this.captureDom = captureDom; } + /** + * Enables full page screenshots + */ + public void enableFullPageScreenshots() { + this.fullPageScreenshotConfig = new FullPageScreenshotConfig.Builder().build(); + } + /** * Enables full page screenshots * - * @param fullPageScreenshotConfig activation of DOM Capture. + * @param fullPageScreenshotConfig config for full page screenshots */ - public void setFullPageScreenshotConfig(FullPageScreenshotConfig fullPageScreenshotConfig) { + public void enableFullPageScreenshots(FullPageScreenshotConfig fullPageScreenshotConfig) { this.fullPageScreenshotConfig = fullPageScreenshotConfig; } From 4e49d283975f9774789949d59b26b0d16a901679 Mon Sep 17 00:00:00 2001 From: Pawel Tomaszewski Date: Fri, 17 May 2024 12:05:33 +0200 Subject: [PATCH 4/5] remove toolBarShadowPadding and addressBarShadowPadding in fps --- .../java/com/saucelabs/visual/VisualApi.java | 8 ++-- .../model/FullPageScreenshotConfig.java | 44 +++++-------------- 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java b/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java index 86918d11..c64a3318 100644 --- a/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java +++ b/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java @@ -199,9 +199,7 @@ public void setCaptureDom(Boolean captureDom) { this.captureDom = captureDom; } - /** - * Enables full page screenshots - */ + /** Enables full page screenshots */ public void enableFullPageScreenshots() { this.fullPageScreenshotConfig = new FullPageScreenshotConfig.Builder().build(); } @@ -385,7 +383,9 @@ public void sauceVisualCheck(String snapshotName, CheckOptions options) { input.setClipSelector(clipSelector); } - FullPageScreenshotConfig fullPageScreenshotConfig = Optional.ofNullable(options.getFullPageScreenshotConfig()).orElse(this.fullPageScreenshotConfig); + FullPageScreenshotConfig fullPageScreenshotConfig = + Optional.ofNullable(options.getFullPageScreenshotConfig()) + .orElse(this.fullPageScreenshotConfig); if (fullPageScreenshotConfig != null) { input.setFullPageConfig(fullPageScreenshotConfig); } diff --git a/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java b/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java index 8d548892..575d3244 100644 --- a/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java +++ b/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java @@ -5,38 +5,32 @@ public class FullPageScreenshotConfig { - private int addressBarShadowPadding; private int delayAfterScrollMs; private Boolean disableCSSAnimation; private List hideAfterFirstScroll; private Boolean hideScrollBars; - private int toolBarShadowPadding; private int scrollLimit; - public FullPageScreenshotConfig(int addressBarShadowPadding, int delayAfterScrollMs, Boolean disableCSSAnimation, List hideAfterFirstScroll, Boolean hideScrollBars, int toolBarShadowPadding, int scrollLimit) { - this.addressBarShadowPadding = addressBarShadowPadding; + public FullPageScreenshotConfig( + int delayAfterScrollMs, + Boolean disableCSSAnimation, + List hideAfterFirstScroll, + Boolean hideScrollBars, + int scrollLimit) { this.delayAfterScrollMs = delayAfterScrollMs; this.disableCSSAnimation = disableCSSAnimation; this.hideAfterFirstScroll = hideAfterFirstScroll; this.hideScrollBars = hideScrollBars; - this.toolBarShadowPadding = toolBarShadowPadding; this.scrollLimit = scrollLimit; } public static class Builder { - private int addressBarShadowPadding; private int delayAfterScrollMs; private Boolean disableCSSAnimation; private List hideAfterFirstScroll; private Boolean hideScrollBars; - private int toolBarShadowPadding; private int scrollLimit; - public Builder withAddressBarShadowPadding(int addressBarShadowPadding) { - this.addressBarShadowPadding = addressBarShadowPadding; - return this; - } - public Builder withDelayAfterScrollMs(int delayAfterScrollMs) { this.delayAfterScrollMs = delayAfterScrollMs; return this; @@ -57,11 +51,6 @@ public Builder withHideScrollBars(Boolean hideScrollBars) { return this; } - public Builder withToolBarShadowPadding(int toolBarShadowPadding) { - this.toolBarShadowPadding = toolBarShadowPadding; - return this; - } - public Builder withScrollLimit(int scrollLimit) { if (scrollLimit > 0 && scrollLimit <= 10) { this.scrollLimit = scrollLimit; @@ -73,16 +62,15 @@ public Builder withScrollLimit(int scrollLimit) { } public FullPageScreenshotConfig build() { - return new FullPageScreenshotConfig(addressBarShadowPadding, delayAfterScrollMs, disableCSSAnimation, hideAfterFirstScroll, hideScrollBars, toolBarShadowPadding, scrollLimit); + return new FullPageScreenshotConfig( + delayAfterScrollMs, + disableCSSAnimation, + hideAfterFirstScroll, + hideScrollBars, + scrollLimit); } } - public int getAddressBarShadowPadding() { - return addressBarShadowPadding; - } - public void setAddressBarShadowPadding(int addressBarShadowPadding) { - this.addressBarShadowPadding = addressBarShadowPadding; - } public int getDelayAfterScrollMs() { return delayAfterScrollMs; } @@ -115,14 +103,6 @@ public void setHideScrollBars(Boolean hideScrollBars) { this.hideScrollBars = hideScrollBars; } - public int getToolBarShadowPadding() { - return toolBarShadowPadding; - } - - public void setToolBarShadowPadding(int toolBarShadowPadding) { - this.toolBarShadowPadding = toolBarShadowPadding; - } - public int getScrollLimit() { return scrollLimit; } From efcce27571735ceb540bee6a7e07903835d6bf87 Mon Sep 17 00:00:00 2001 From: Pawel Tomaszewski Date: Tue, 21 May 2024 11:17:59 +0200 Subject: [PATCH 5/5] remove scroll limit validation --- .../saucelabs/visual/model/FullPageScreenshotConfig.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java b/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java index 575d3244..a96e6018 100644 --- a/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java +++ b/visual-java/src/main/java/com/saucelabs/visual/model/FullPageScreenshotConfig.java @@ -52,12 +52,7 @@ public Builder withHideScrollBars(Boolean hideScrollBars) { } public Builder withScrollLimit(int scrollLimit) { - if (scrollLimit > 0 && scrollLimit <= 10) { - this.scrollLimit = scrollLimit; - } else { - this.scrollLimit = 10; - } - + this.scrollLimit = scrollLimit; return this; }