From 2a8dcb9cc060bc9a369272ac4f6f5dcb576e67c5 Mon Sep 17 00:00:00 2001 From: "robert.kmieciak" Date: Wed, 18 Jul 2018 12:44:01 +0200 Subject: [PATCH 01/29] Suite files udpated for chrome - line number changes, filter rules changes. Removed form which caused screen comparator stabilization issues. --- .../main/resources/page_template/template.html | 18 ------------------ .../src/main/webapp/includes/bodyContent.jsp | 18 ------------------ .../partials/accessibility-filtered.xml | 2 +- .../partials/js-errors-filter-by-error.xml | 8 ++++---- .../js-errors-filter-by-source-and-line.xml | 6 +++--- .../test-suite/partials/js-errors.xml | 9 ++++++--- .../test-suite/partials/w3c-html5-filtered.xml | 12 ++++++------ 7 files changed, 20 insertions(+), 53 deletions(-) diff --git a/integration-tests/sample-site/src/main/resources/page_template/template.html b/integration-tests/sample-site/src/main/resources/page_template/template.html index 8bb435b63..f24c4cc3b 100644 --- a/integration-tests/sample-site/src/main/resources/page_template/template.html +++ b/integration-tests/sample-site/src/main/resources/page_template/template.html @@ -267,24 +267,6 @@

Forms

-
- -
-
-
-
diff --git a/integration-tests/sample-site/src/main/webapp/includes/bodyContent.jsp b/integration-tests/sample-site/src/main/webapp/includes/bodyContent.jsp index 7dfb9b95a..ae826b8ac 100644 --- a/integration-tests/sample-site/src/main/webapp/includes/bodyContent.jsp +++ b/integration-tests/sample-site/src/main/webapp/includes/bodyContent.jsp @@ -250,24 +250,6 @@
-
- -
-
-
-
diff --git a/integration-tests/test-suite/partials/accessibility-filtered.xml b/integration-tests/test-suite/partials/accessibility-filtered.xml index a66adbc08..b999dd313 100644 --- a/integration-tests/test-suite/partials/accessibility-filtered.xml +++ b/integration-tests/test-suite/partials/accessibility-filtered.xml @@ -94,7 +94,7 @@ - + diff --git a/integration-tests/test-suite/partials/js-errors-filter-by-error.xml b/integration-tests/test-suite/partials/js-errors-filter-by-error.xml index b34e111dc..174819197 100644 --- a/integration-tests/test-suite/partials/js-errors-filter-by-error.xml +++ b/integration-tests/test-suite/partials/js-errors-filter-by-error.xml @@ -45,8 +45,8 @@ - - + + @@ -63,8 +63,8 @@ - - + + diff --git a/integration-tests/test-suite/partials/js-errors-filter-by-source-and-line.xml b/integration-tests/test-suite/partials/js-errors-filter-by-source-and-line.xml index 080e0f2c4..a989e8972 100644 --- a/integration-tests/test-suite/partials/js-errors-filter-by-source-and-line.xml +++ b/integration-tests/test-suite/partials/js-errors-filter-by-source-and-line.xml @@ -91,7 +91,7 @@ + name="S-comparator-JsErrors-filter-by-source-and-line-number-21-and-371"> @@ -99,8 +99,8 @@ - - + + + @@ -42,7 +43,9 @@ - + + + @@ -71,8 +74,8 @@ - - + + diff --git a/integration-tests/test-suite/partials/w3c-html5-filtered.xml b/integration-tests/test-suite/partials/w3c-html5-filtered.xml index 88aed39f1..3664e0beb 100644 --- a/integration-tests/test-suite/partials/w3c-html5-filtered.xml +++ b/integration-tests/test-suite/partials/w3c-html5-filtered.xml @@ -48,9 +48,9 @@ - - - + + + @@ -90,9 +90,9 @@ - - - + + + From ae0ac303a3cf40a6154ea5398dfa640d5448552d Mon Sep 17 00:00:00 2001 From: Slasheruus <41109829+Slasheruus@users.noreply.github.com> Date: Thu, 19 Jul 2018 12:54:21 +0200 Subject: [PATCH 02/29] ChromeEntirePageScreen --- .../resolution/ResolutionModifier.java | 50 +++++++++---------- .../resolution/ResolutionModifierTest.java | 18 ++----- .../chrome/ChromeWebDriverFactory.java | 1 + 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index 6d087140a..2b51e4cfd 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -20,9 +20,13 @@ import com.cognifide.aet.job.api.collector.CollectorJob; import com.cognifide.aet.job.api.exceptions.ParametersException; import com.cognifide.aet.job.api.exceptions.ProcessingException; + import java.util.Map; +import java.util.Optional; + import org.apache.commons.lang3.math.NumberUtils; import org.openqa.selenium.Dimension; +import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver.Window; import org.slf4j.Logger; @@ -34,22 +38,17 @@ public class ResolutionModifier implements CollectorJob { private static final Logger LOG = LoggerFactory.getLogger(ResolutionModifier.class); - private static final String PARAM_MAXIMIZE = "maximize"; - private static final String WIDTH_PARAM = "width"; private static final String HEIGHT_PARAM = "height"; - private static final int MAX_SIZE = 100000; + private static final int MAX_SIZE = 15000; private final WebDriver webDriver; private int width; - private int height; - - @Deprecated - private boolean maximize; + private Optional height; public ResolutionModifier(WebDriver webDriver) { this.webDriver = webDriver; @@ -64,33 +63,34 @@ public CollectorStepResult collect() throws ProcessingException { @Override public void setParameters(Map params) throws ParametersException { - String paramValue = params.get(PARAM_MAXIMIZE); - maximize = Boolean.valueOf(paramValue); - - if (params.containsKey(WIDTH_PARAM) && params.containsKey(HEIGHT_PARAM)) { + if (params.containsKey(WIDTH_PARAM)) { width = NumberUtils.toInt(params.get(WIDTH_PARAM)); ParametersValidator.checkRange(width, 1, MAX_SIZE, "Width should be greater than 0"); - - height = NumberUtils.toInt(params.get(HEIGHT_PARAM)); - ParametersValidator.checkRange(height, 1, MAX_SIZE, "Height should be greater than 0"); - - ParametersValidator.checkParameter(!maximize, - "You cannot maximize the window and specify the dimension"); - } else if (params.containsKey(WIDTH_PARAM) || params.containsKey(HEIGHT_PARAM)) { - throw new ParametersException("You have to specify both width and height"); + if (params.containsKey(HEIGHT_PARAM)) { + height = Optional.of(NumberUtils.toInt(params.get(HEIGHT_PARAM))); + ParametersValidator + .checkRange(height.get(), 1, MAX_SIZE, "Height should be greater than 0"); + } else { + height = Optional.empty(); + } + } else { + throw new ParametersException("You have to specify width, height parameter is optional"); } } private void setResolution(WebDriver webDriver) { Window window = webDriver.manage().window(); - if (maximize) { - window.maximize(); - LOG.error("Trying to maximise window to {}x{}!", window.getSize().getWidth(), - window.getSize().getHeight()); + JavascriptExecutor js = (JavascriptExecutor) webDriver; + int localHeight; + if (height.isPresent()) { + localHeight = height.get(); } else { - LOG.info("Setting resolution to {}x{} ", width, height); - window.setSize(new Dimension(width, height)); + js.executeScript("window.scrollTo(0, document.body.scrollHeight);"); + localHeight = Integer + .parseInt(js.executeScript("return document.body.scrollHeight").toString()); } + LOG.info("Setting resolution to {}x{} ", width, localHeight); + window.setSize(new Dimension(width, localHeight)); } } diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java index 994d03203..5613cbf72 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java @@ -24,6 +24,7 @@ import com.cognifide.aet.job.api.exceptions.ProcessingException; import java.util.Map; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -31,8 +32,10 @@ import org.mockito.runners.MockitoJUnitRunner; import org.openqa.selenium.Dimension; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.remote.RemoteWebDriver; @RunWith(MockitoJUnitRunner.class) +@Ignore("Ignored for POC") public class ResolutionModifierTest { private static final String PARAM_MAXIMIZE = "maximize"; @@ -52,7 +55,7 @@ public class ResolutionModifierTest { private static final int CUSTOM_HEIGHT = 600; @Mock - private WebDriver webDriver; + private RemoteWebDriver webDriver; @Mock private Map params; @@ -119,18 +122,6 @@ public void setParametersTest_maximizeWithWindowSize() throws ParametersExceptio tested.setParameters(params); } - @Test - public void collectTest_maximize() throws ParametersException, ProcessingException { - when(params.get(PARAM_MAXIMIZE)).thenReturn("true"); - - tested.setParameters(params); - tested.collect(); - - verify(window, times(1)).maximize(); - verify(windowDimension, times(1)).getWidth(); - verify(windowDimension, times(1)).getHeight(); - verify(window, never()).setSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT)); - } @Test public void collectTest_setWidthHeight() throws ParametersException, ProcessingException { @@ -142,7 +133,6 @@ public void collectTest_setWidthHeight() throws ParametersException, ProcessingE tested.setParameters(params); tested.collect(); - verify(window, never()).maximize(); verify(windowDimension, never()).getWidth(); verify(windowDimension, never()).getHeight(); verify(window, times(1)).setSize(new Dimension(CUSTOM_WIDTH, CUSTOM_HEIGHT)); diff --git a/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java b/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java index aa405a2bd..c74ed79b4 100644 --- a/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java +++ b/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java @@ -136,6 +136,7 @@ private DesiredCapabilities setupCapabilities() { ChromeOptions options = new ChromeOptions(); options.addArguments("--disable-plugins"); + options.addArguments("--headless"); // @PiotrWolynski add this capabilities.setCapability(ChromeOptions.CAPABILITY, options); From 8a6f67b1e81f551fb47dac0b914e42e6c750d5b0 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Thu, 19 Jul 2018 16:19:00 +0200 Subject: [PATCH 03/29] Chrome limit handler && disabled scrolling --- .../common/modifiers/resolution/ResolutionModifier.java | 7 ++++++- .../aet/worker/drivers/chrome/ChromeWebDriverFactory.java | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index 2b51e4cfd..f3c725ead 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -29,6 +29,7 @@ import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver.Window; +import org.openqa.selenium.remote.RemoteWebDriver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -81,14 +82,18 @@ public void setParameters(Map params) throws ParametersException private void setResolution(WebDriver webDriver) { Window window = webDriver.manage().window(); JavascriptExecutor js = (JavascriptExecutor) webDriver; + String browserName = ((RemoteWebDriver) webDriver).getCapabilities().getBrowserName().toLowerCase(); int localHeight; if (height.isPresent()) { localHeight = height.get(); } else { - js.executeScript("window.scrollTo(0, document.body.scrollHeight);"); localHeight = Integer .parseInt(js.executeScript("return document.body.scrollHeight").toString()); } + if(browserName.equals("chrome") && localHeight > 15000){ + LOG.info("Height is over browser limit, changing height to 15000"); + localHeight = 15000; + } LOG.info("Setting resolution to {}x{} ", width, localHeight); window.setSize(new Dimension(width, localHeight)); } diff --git a/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java b/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java index c74ed79b4..4dd38932c 100644 --- a/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java +++ b/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java @@ -137,6 +137,7 @@ private DesiredCapabilities setupCapabilities() { ChromeOptions options = new ChromeOptions(); options.addArguments("--disable-plugins"); options.addArguments("--headless"); // @PiotrWolynski add this + options.addArguments("--hide-scrollbars"); capabilities.setCapability(ChromeOptions.CAPABILITY, options); From bc537b4447b272ab182bf06a06b898250ed2d6ce Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Thu, 19 Jul 2018 16:48:42 +0200 Subject: [PATCH 04/29] Refactoring --- .../common/modifiers/resolution/ResolutionModifier.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index f3c725ead..4af2a6efb 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -89,10 +89,10 @@ private void setResolution(WebDriver webDriver) { } else { localHeight = Integer .parseInt(js.executeScript("return document.body.scrollHeight").toString()); - } - if(browserName.equals("chrome") && localHeight > 15000){ - LOG.info("Height is over browser limit, changing height to 15000"); - localHeight = 15000; + if(browserName.equals("chrome") && localHeight > MAX_SIZE){ + LOG.info("Height is over browser limit, changing height to " + MAX_SIZE); + localHeight = MAX_SIZE; + } } LOG.info("Setting resolution to {}x{} ", width, localHeight); window.setSize(new Dimension(width, localHeight)); From c3f9f4fcf7fdc2e75564c2d72c64d49cb1e7d86e Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Fri, 20 Jul 2018 09:52:02 +0200 Subject: [PATCH 05/29] Tests for ResolutionModifier update --- .../resolution/ResolutionModifier.java | 2 +- .../resolution/ResolutionModifierTest.java | 40 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index 4af2a6efb..571549a6b 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -82,11 +82,11 @@ public void setParameters(Map params) throws ParametersException private void setResolution(WebDriver webDriver) { Window window = webDriver.manage().window(); JavascriptExecutor js = (JavascriptExecutor) webDriver; - String browserName = ((RemoteWebDriver) webDriver).getCapabilities().getBrowserName().toLowerCase(); int localHeight; if (height.isPresent()) { localHeight = height.get(); } else { + String browserName = ((RemoteWebDriver) webDriver).getCapabilities().getBrowserName().toLowerCase(); localHeight = Integer .parseInt(js.executeScript("return document.body.scrollHeight").toString()); if(browserName.equals("chrome") && localHeight > MAX_SIZE){ diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java index 5613cbf72..512283a3c 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java @@ -23,6 +23,8 @@ import com.cognifide.aet.job.api.exceptions.ParametersException; import com.cognifide.aet.job.api.exceptions.ProcessingException; import java.util.Map; + +import com.sun.jna.platform.win32.WinDef; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -30,12 +32,13 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import org.openqa.selenium.Capabilities; import org.openqa.selenium.Dimension; +import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; @RunWith(MockitoJUnitRunner.class) -@Ignore("Ignored for POC") public class ResolutionModifierTest { private static final String PARAM_MAXIMIZE = "maximize"; @@ -54,9 +57,14 @@ public class ResolutionModifierTest { private static final int CUSTOM_HEIGHT = 600; + private static final int CHROME_LIMIT = 15000; + @Mock private RemoteWebDriver webDriver; + @Mock + private Capabilities capabilities; + @Mock private Map params; @@ -75,6 +83,7 @@ public class ResolutionModifierTest { @Before public void setUp() { when(webDriver.manage()).thenReturn(options); + when(webDriver.getCapabilities()).thenReturn(capabilities); when(options.window()).thenReturn(window); when(window.getSize()).thenReturn(windowDimension); when(windowDimension.getWidth()).thenReturn(WINDOW_WIDTH); @@ -113,16 +122,6 @@ public void setParametersTest_height0() throws ParametersException { tested.setParameters(params); } - @Test(expected = ParametersException.class) - public void setParametersTest_maximizeWithWindowSize() throws ParametersException { - when(params.get(PARAM_MAXIMIZE)).thenReturn("true"); - when(params.containsKey(HEIGHT_PARAM)).thenReturn(true); - when(params.get(HEIGHT_PARAM)).thenReturn("100"); - - tested.setParameters(params); - } - - @Test public void collectTest_setWidthHeight() throws ParametersException, ProcessingException { when(params.containsKey(HEIGHT_PARAM)).thenReturn(true); @@ -138,19 +137,20 @@ public void collectTest_setWidthHeight() throws ParametersException, ProcessingE verify(window, times(1)).setSize(new Dimension(CUSTOM_WIDTH, CUSTOM_HEIGHT)); } - @Test(expected = ParametersException.class) - public void collectTest_setOnlyHeight() throws ParametersException, ProcessingException { - when(params.containsKey(HEIGHT_PARAM)).thenReturn(true); - when(params.get(HEIGHT_PARAM)).thenReturn("" + CUSTOM_HEIGHT); - - tested.setParameters(params); - } - - @Test(expected = ParametersException.class) + @Test public void collectTest_setOnlyWidth() throws ParametersException, ProcessingException { when(params.containsKey(WIDTH_PARAM)).thenReturn(true); + when(params.containsKey(HEIGHT_PARAM)).thenReturn(false); when(params.get(WIDTH_PARAM)).thenReturn("" + CUSTOM_WIDTH); + when(capabilities.getBrowserName()).thenReturn("chrome"); + when(webDriver.executeScript("return document.body.scrollHeight")).thenReturn(Long.parseLong( "" + CHROME_LIMIT + 5000)); + tested.setParameters(params); + tested.collect(); + + verify(windowDimension, never()).getWidth(); + verify(windowDimension, never()).getHeight(); + verify(window, times(1)).setSize(new Dimension(CUSTOM_WIDTH, CHROME_LIMIT)); } } From 26772c8c8eb048665e978d85f9611537e4ea4232 Mon Sep 17 00:00:00 2001 From: "robert.kmieciak" Date: Fri, 20 Jul 2018 11:15:59 +0200 Subject: [PATCH 06/29] Setting resolution for chrome screen comparator --- .../partials-templates/executejavascript.xml | 4 ++++ integration-tests/test-suite/partials/click.xml | 1 + integration-tests/test-suite/partials/layout.xml | 10 +++++++--- integration-tests/test-suite/partials/replacetext.xml | 1 + .../test-suite/partials/sleep-modifier.xml | 2 ++ .../partials/wait-for-element-to-be-visible.xml | 2 ++ .../test-suite/partials/wait-for-image-completion.xml | 3 +++ .../partials/wait-for-page-loaded-modifier.xml | 2 ++ 8 files changed, 22 insertions(+), 3 deletions(-) diff --git a/integration-tests/test-suite/partials-templates/executejavascript.xml b/integration-tests/test-suite/partials-templates/executejavascript.xml index 46e658fcd..d47b7856a 100644 --- a/integration-tests/test-suite/partials-templates/executejavascript.xml +++ b/integration-tests/test-suite/partials-templates/executejavascript.xml @@ -24,6 +24,7 @@ + @@ -39,6 +40,7 @@ + @@ -53,6 +55,7 @@ + @@ -67,6 +70,7 @@ + diff --git a/integration-tests/test-suite/partials/click.xml b/integration-tests/test-suite/partials/click.xml index ac10ab355..cb08c7c0f 100644 --- a/integration-tests/test-suite/partials/click.xml +++ b/integration-tests/test-suite/partials/click.xml @@ -24,6 +24,7 @@ + diff --git a/integration-tests/test-suite/partials/layout.xml b/integration-tests/test-suite/partials/layout.xml index 913c61447..ab721dae6 100644 --- a/integration-tests/test-suite/partials/layout.xml +++ b/integration-tests/test-suite/partials/layout.xml @@ -24,6 +24,7 @@ + @@ -50,6 +51,7 @@ + @@ -65,6 +67,7 @@ + @@ -79,6 +82,7 @@ + @@ -93,7 +97,7 @@ - + @@ -122,7 +126,7 @@ - + @@ -137,7 +141,7 @@ - + diff --git a/integration-tests/test-suite/partials/replacetext.xml b/integration-tests/test-suite/partials/replacetext.xml index 5cab79a57..13344ef0f 100644 --- a/integration-tests/test-suite/partials/replacetext.xml +++ b/integration-tests/test-suite/partials/replacetext.xml @@ -24,6 +24,7 @@ + diff --git a/integration-tests/test-suite/partials/sleep-modifier.xml b/integration-tests/test-suite/partials/sleep-modifier.xml index 303d86a1d..ca11af3f3 100644 --- a/integration-tests/test-suite/partials/sleep-modifier.xml +++ b/integration-tests/test-suite/partials/sleep-modifier.xml @@ -24,6 +24,7 @@ + @@ -37,6 +38,7 @@ + diff --git a/integration-tests/test-suite/partials/wait-for-element-to-be-visible.xml b/integration-tests/test-suite/partials/wait-for-element-to-be-visible.xml index 28bbff0a4..001043727 100644 --- a/integration-tests/test-suite/partials/wait-for-element-to-be-visible.xml +++ b/integration-tests/test-suite/partials/wait-for-element-to-be-visible.xml @@ -24,6 +24,7 @@ + @@ -38,6 +39,7 @@ + diff --git a/integration-tests/test-suite/partials/wait-for-image-completion.xml b/integration-tests/test-suite/partials/wait-for-image-completion.xml index c1c4e0a0b..dbd1f55dc 100644 --- a/integration-tests/test-suite/partials/wait-for-image-completion.xml +++ b/integration-tests/test-suite/partials/wait-for-image-completion.xml @@ -24,6 +24,7 @@ + @@ -38,6 +39,7 @@ + @@ -52,6 +54,7 @@ + diff --git a/integration-tests/test-suite/partials/wait-for-page-loaded-modifier.xml b/integration-tests/test-suite/partials/wait-for-page-loaded-modifier.xml index 160abc871..42aad04bb 100644 --- a/integration-tests/test-suite/partials/wait-for-page-loaded-modifier.xml +++ b/integration-tests/test-suite/partials/wait-for-page-loaded-modifier.xml @@ -24,6 +24,7 @@ + @@ -38,6 +39,7 @@ + From 330a8a6a9431f80e8009c7d837d915082573b5f4 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Fri, 20 Jul 2018 11:42:35 +0200 Subject: [PATCH 07/29] Collect page height update --- .../modifiers/resolution/ResolutionModifier.java | 10 +++++----- .../modifiers/resolution/ResolutionModifierTest.java | 12 +++--------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index 571549a6b..ac453e43d 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Optional; +import java.util.concurrent.TimeUnit; import org.apache.commons.lang3.math.NumberUtils; import org.openqa.selenium.Dimension; @@ -87,15 +88,14 @@ private void setResolution(WebDriver webDriver) { localHeight = height.get(); } else { String browserName = ((RemoteWebDriver) webDriver).getCapabilities().getBrowserName().toLowerCase(); - localHeight = Integer - .parseInt(js.executeScript("return document.body.scrollHeight").toString()); + window.setSize(new Dimension(width, 300)); //Pre-run with correct width + localHeight = Integer.parseInt(js.executeScript("return document.body.scrollHeight").toString()); if(browserName.equals("chrome") && localHeight > MAX_SIZE){ - LOG.info("Height is over browser limit, changing height to " + MAX_SIZE); - localHeight = MAX_SIZE; + LOG.info("Height is over browser limit, changing height to " + MAX_SIZE); + localHeight = MAX_SIZE; } } LOG.info("Setting resolution to {}x{} ", width, localHeight); window.setSize(new Dimension(width, localHeight)); } - } diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java index 512283a3c..5f67c475d 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java @@ -15,18 +15,11 @@ */ package com.cognifide.aet.job.common.modifiers.resolution; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import com.cognifide.aet.job.api.exceptions.ParametersException; import com.cognifide.aet.job.api.exceptions.ProcessingException; import java.util.Map; -import com.sun.jna.platform.win32.WinDef; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -34,10 +27,11 @@ import org.mockito.runners.MockitoJUnitRunner; import org.openqa.selenium.Capabilities; import org.openqa.selenium.Dimension; -import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; +import static org.mockito.Mockito.*; + @RunWith(MockitoJUnitRunner.class) public class ResolutionModifierTest { @@ -151,6 +145,6 @@ public void collectTest_setOnlyWidth() throws ParametersException, ProcessingExc verify(windowDimension, never()).getWidth(); verify(windowDimension, never()).getHeight(); - verify(window, times(1)).setSize(new Dimension(CUSTOM_WIDTH, CHROME_LIMIT)); + verify(window, atLeastOnce()).setSize(new Dimension(CUSTOM_WIDTH, CHROME_LIMIT)); } } From 834a837064f950abca1323d966df24faacd92a5e Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Fri, 20 Jul 2018 13:52:31 +0200 Subject: [PATCH 08/29] Wiki - Hide Modifier update --- documentation/src/main/wiki/HideModifier.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/documentation/src/main/wiki/HideModifier.md b/documentation/src/main/wiki/HideModifier.md index d4d677191..9f57aa7f5 100644 --- a/documentation/src/main/wiki/HideModifier.md +++ b/documentation/src/main/wiki/HideModifier.md @@ -6,7 +6,8 @@ Module name: **hide** | ! Important information | |:----------------------- | -| In order to use this modifier it must be declared after the open module in the definition of the test suite XML. | +| *In order to use this modifier it must be declared after the open module in the definition of the test suite XML. +*In order to use this modifier with Resolution Modifier it must be declared before the Resolution Modifier.| ##### Parameters From e0120aa227fda62d49caf52c64aff09aa474b001 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Mon, 23 Jul 2018 12:32:20 +0200 Subject: [PATCH 09/29] Changed pageLoadStrategy && updated ResolutionModifierTest --- .../job/common/modifiers/resolution/ResolutionModifierTest.java | 2 +- .../aet/worker/drivers/chrome/ChromeWebDriverFactory.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java index 5f67c475d..b3a8a93b0 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java @@ -138,7 +138,7 @@ public void collectTest_setOnlyWidth() throws ParametersException, ProcessingExc when(params.get(WIDTH_PARAM)).thenReturn("" + CUSTOM_WIDTH); when(capabilities.getBrowserName()).thenReturn("chrome"); - when(webDriver.executeScript("return document.body.scrollHeight")).thenReturn(Long.parseLong( "" + CHROME_LIMIT + 5000)); + when(webDriver.executeScript("return document.body.scrollHeight")).thenReturn(Long.parseLong( CHROME_LIMIT + 5000 + "")); tested.setParameters(params); tested.collect(); diff --git a/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java b/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java index 4dd38932c..4fe36c1cc 100644 --- a/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java +++ b/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java @@ -129,6 +129,7 @@ private WebDriver getChromeDriver(DesiredCapabilities capabilities) private DesiredCapabilities setupCapabilities() { final DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); + capabilities.setCapability(CapabilityType.PAGE_LOAD_STRATEGY, "none"); final LoggingPreferences loggingPreferences = new LoggingPreferences(); loggingPreferences.enable(LogType.BROWSER, Level.ALL); From ed587b2852eac35673fc7125bf55998ccf41909a Mon Sep 17 00:00:00 2001 From: Tomasz Kaik Date: Mon, 23 Jul 2018 13:59:56 +0200 Subject: [PATCH 10/29] New chrome arg to fix headless+proxy screenshot issue --- .../aet/worker/drivers/chrome/ChromeWebDriverFactory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java b/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java index 4fe36c1cc..5f019deaa 100644 --- a/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java +++ b/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java @@ -137,8 +137,9 @@ private DesiredCapabilities setupCapabilities() { ChromeOptions options = new ChromeOptions(); options.addArguments("--disable-plugins"); - options.addArguments("--headless"); // @PiotrWolynski add this + options.addArguments("--headless"); options.addArguments("--hide-scrollbars"); + options.setAcceptInsecureCerts(true); capabilities.setCapability(ChromeOptions.CAPABILITY, options); From 503089f57b41175909a0cfd2dcec5c2d22cbaff6 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Mon, 23 Jul 2018 15:37:24 +0200 Subject: [PATCH 11/29] Revert pageLoadStrategy --- .../aet/worker/drivers/chrome/ChromeWebDriverFactory.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java b/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java index 5f019deaa..62765824c 100644 --- a/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java +++ b/core/worker/src/main/java/com/cognifide/aet/worker/drivers/chrome/ChromeWebDriverFactory.java @@ -129,7 +129,6 @@ private WebDriver getChromeDriver(DesiredCapabilities capabilities) private DesiredCapabilities setupCapabilities() { final DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); - capabilities.setCapability(CapabilityType.PAGE_LOAD_STRATEGY, "none"); final LoggingPreferences loggingPreferences = new LoggingPreferences(); loggingPreferences.enable(LogType.BROWSER, Level.ALL); From a5fb1d90f78cde37ce526571d6603737ca2277c7 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Wed, 25 Jul 2018 14:29:26 +0200 Subject: [PATCH 12/29] S-comparator-Layout-Hide-leaveBlankSpace-false - ResolutionModifier after HideModifier --- integration-tests/test-suite/partials/layout.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/test-suite/partials/layout.xml b/integration-tests/test-suite/partials/layout.xml index ab721dae6..e73703e5e 100644 --- a/integration-tests/test-suite/partials/layout.xml +++ b/integration-tests/test-suite/partials/layout.xml @@ -82,9 +82,9 @@ - + From a2cff6723d7ea90d9d0e058159288141ddd20e7d Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Thu, 26 Jul 2018 12:37:17 +0200 Subject: [PATCH 13/29] ResolutionModifier - refactor --- .../modifiers/resolution/ResolutionModifier.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index ac453e43d..34cae83ac 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -23,7 +23,6 @@ import java.util.Map; import java.util.Optional; -import java.util.concurrent.TimeUnit; import org.apache.commons.lang3.math.NumberUtils; import org.openqa.selenium.Dimension; @@ -46,6 +45,8 @@ public class ResolutionModifier implements CollectorJob { private static final int MAX_SIZE = 15000; + private static final int INITIAL_HEIGHT = 300; + private final WebDriver webDriver; private int width; @@ -87,10 +88,12 @@ private void setResolution(WebDriver webDriver) { if (height.isPresent()) { localHeight = height.get(); } else { - String browserName = ((RemoteWebDriver) webDriver).getCapabilities().getBrowserName().toLowerCase(); - window.setSize(new Dimension(width, 300)); //Pre-run with correct width - localHeight = Integer.parseInt(js.executeScript("return document.body.scrollHeight").toString()); - if(browserName.equals("chrome") && localHeight > MAX_SIZE){ + String browserName = ((RemoteWebDriver) webDriver).getCapabilities().getBrowserName() + .toLowerCase(); + window.setSize(new Dimension(width, INITIAL_HEIGHT)); //Pre-run with correct width + localHeight = Integer + .parseInt(js.executeScript("return document.body.scrollHeight").toString()); + if (browserName.equals("chrome") && localHeight > MAX_SIZE) { LOG.info("Height is over browser limit, changing height to " + MAX_SIZE); localHeight = MAX_SIZE; } From 2da4b7e89fb5a3678480b884f3492adb9f94aad1 Mon Sep 17 00:00:00 2001 From: Tomasz Kaik Date: Thu, 26 Jul 2018 14:43:00 +0200 Subject: [PATCH 14/29] Decreased wait timeouts for tests stabilizations --- integration-tests/test-suite/partials/sleep-modifier.xml | 3 ++- .../test-suite/partials/wait-for-element-to-be-visible.xml | 2 +- .../test-suite/partials/wait-for-image-completion.xml | 2 +- .../test-suite/partials/wait-for-page-loaded-modifier.xml | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/integration-tests/test-suite/partials/sleep-modifier.xml b/integration-tests/test-suite/partials/sleep-modifier.xml index ca11af3f3..0cbd0e81b 100644 --- a/integration-tests/test-suite/partials/sleep-modifier.xml +++ b/integration-tests/test-suite/partials/sleep-modifier.xml @@ -35,11 +35,12 @@ + - + diff --git a/integration-tests/test-suite/partials/wait-for-element-to-be-visible.xml b/integration-tests/test-suite/partials/wait-for-element-to-be-visible.xml index 001043727..40580dfb1 100644 --- a/integration-tests/test-suite/partials/wait-for-element-to-be-visible.xml +++ b/integration-tests/test-suite/partials/wait-for-element-to-be-visible.xml @@ -40,7 +40,7 @@ - + diff --git a/integration-tests/test-suite/partials/wait-for-image-completion.xml b/integration-tests/test-suite/partials/wait-for-image-completion.xml index dbd1f55dc..20dbd4058 100644 --- a/integration-tests/test-suite/partials/wait-for-image-completion.xml +++ b/integration-tests/test-suite/partials/wait-for-image-completion.xml @@ -40,7 +40,7 @@ - + diff --git a/integration-tests/test-suite/partials/wait-for-page-loaded-modifier.xml b/integration-tests/test-suite/partials/wait-for-page-loaded-modifier.xml index 42aad04bb..0ab210049 100644 --- a/integration-tests/test-suite/partials/wait-for-page-loaded-modifier.xml +++ b/integration-tests/test-suite/partials/wait-for-page-loaded-modifier.xml @@ -41,7 +41,7 @@ - + From b5b0eba85cf4320b7d05726c69c505b68682f5ed Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Thu, 26 Jul 2018 14:52:57 +0200 Subject: [PATCH 15/29] ResolutionModifier - refactor --- .../common/modifiers/resolution/ResolutionModifier.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index 34cae83ac..2c04f0b79 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -43,6 +43,10 @@ public class ResolutionModifier implements CollectorJob { private static final String HEIGHT_PARAM = "height"; + private static final String BROWSER_NAME_CHROME = "chrome"; + + private static final String JAVASCRIPT_GET_BODY_HEIGHT = "return document.body.scrollHeight"; + private static final int MAX_SIZE = 15000; private static final int INITIAL_HEIGHT = 300; @@ -92,8 +96,8 @@ private void setResolution(WebDriver webDriver) { .toLowerCase(); window.setSize(new Dimension(width, INITIAL_HEIGHT)); //Pre-run with correct width localHeight = Integer - .parseInt(js.executeScript("return document.body.scrollHeight").toString()); - if (browserName.equals("chrome") && localHeight > MAX_SIZE) { + .parseInt(js.executeScript(JAVASCRIPT_GET_BODY_HEIGHT).toString()); + if (browserName.equals(BROWSER_NAME_CHROME) && localHeight > MAX_SIZE) { LOG.info("Height is over browser limit, changing height to " + MAX_SIZE); localHeight = MAX_SIZE; } From b47010315e259a48878b5b9d3c96ff0e72ce8a17 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Fri, 27 Jul 2018 10:16:36 +0200 Subject: [PATCH 16/29] ResolutionModifierTest - update & refactor --- .../modifiers/resolution/ResolutionModifierTest.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java index b3a8a93b0..887061bd1 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java @@ -35,8 +35,6 @@ @RunWith(MockitoJUnitRunner.class) public class ResolutionModifierTest { - private static final String PARAM_MAXIMIZE = "maximize"; - private static final String WIDTH_PARAM = "width"; private static final String HEIGHT_PARAM = "height"; @@ -131,6 +129,13 @@ public void collectTest_setWidthHeight() throws ParametersException, ProcessingE verify(window, times(1)).setSize(new Dimension(CUSTOM_WIDTH, CUSTOM_HEIGHT)); } + @Test(expected = ParametersException.class) + public void collectTest_setOnlyHeight() throws ParametersException { + when(params.containsKey(HEIGHT_PARAM)).thenReturn(true); + when(params.get(HEIGHT_PARAM)).thenReturn("" + CUSTOM_HEIGHT); + tested.setParameters(params); + } + @Test public void collectTest_setOnlyWidth() throws ParametersException, ProcessingException { when(params.containsKey(WIDTH_PARAM)).thenReturn(true); @@ -138,7 +143,8 @@ public void collectTest_setOnlyWidth() throws ParametersException, ProcessingExc when(params.get(WIDTH_PARAM)).thenReturn("" + CUSTOM_WIDTH); when(capabilities.getBrowserName()).thenReturn("chrome"); - when(webDriver.executeScript("return document.body.scrollHeight")).thenReturn(Long.parseLong( CHROME_LIMIT + 5000 + "")); + when(webDriver.executeScript("return document.body.scrollHeight")) + .thenReturn(CHROME_LIMIT + 5000L); tested.setParameters(params); tested.collect(); From 63de36c90a57b9d6ba2df2d909280c85ac960756 Mon Sep 17 00:00:00 2001 From: "robert.kmieciak" Date: Fri, 27 Jul 2018 11:19:14 +0200 Subject: [PATCH 17/29] Adjustments for Chrome compatibility --- integration-tests/test-suite/partials/layout.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/test-suite/partials/layout.xml b/integration-tests/test-suite/partials/layout.xml index ab721dae6..14ca62a8b 100644 --- a/integration-tests/test-suite/partials/layout.xml +++ b/integration-tests/test-suite/partials/layout.xml @@ -82,9 +82,9 @@ - + From 69de42ea678f4d30d15ebdc308ac1baa2f3b1b51 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Fri, 27 Jul 2018 12:11:48 +0200 Subject: [PATCH 18/29] ResolutionModifierTest - new test & refactor, ResolutionModifier - refactor --- .../resolution/ResolutionModifier.java | 9 ++---- .../resolution/ResolutionModifierTest.java | 32 +++++++++++++++---- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index 2c04f0b79..e361673c9 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -29,7 +29,6 @@ import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver.Window; -import org.openqa.selenium.remote.RemoteWebDriver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,8 +42,6 @@ public class ResolutionModifier implements CollectorJob { private static final String HEIGHT_PARAM = "height"; - private static final String BROWSER_NAME_CHROME = "chrome"; - private static final String JAVASCRIPT_GET_BODY_HEIGHT = "return document.body.scrollHeight"; private static final int MAX_SIZE = 15000; @@ -92,12 +89,10 @@ private void setResolution(WebDriver webDriver) { if (height.isPresent()) { localHeight = height.get(); } else { - String browserName = ((RemoteWebDriver) webDriver).getCapabilities().getBrowserName() - .toLowerCase(); - window.setSize(new Dimension(width, INITIAL_HEIGHT)); //Pre-run with correct width + window.setSize(new Dimension(width, INITIAL_HEIGHT)); localHeight = Integer .parseInt(js.executeScript(JAVASCRIPT_GET_BODY_HEIGHT).toString()); - if (browserName.equals(BROWSER_NAME_CHROME) && localHeight > MAX_SIZE) { + if (localHeight > MAX_SIZE) { LOG.info("Height is over browser limit, changing height to " + MAX_SIZE); localHeight = MAX_SIZE; } diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java index 887061bd1..d1b833c60 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java @@ -41,6 +41,8 @@ public class ResolutionModifierTest { private static final String NOT_A_NUMBER = "NaN"; + private static final String JAVASCRIPT_GET_BODY_HEIGHT = "return document.body.scrollHeight"; + private static final int WINDOW_WIDTH = 1024; private static final int WINDOW_HEIGHT = 768; @@ -49,7 +51,7 @@ public class ResolutionModifierTest { private static final int CUSTOM_HEIGHT = 600; - private static final int CHROME_LIMIT = 15000; + private static final int BROWSER_HEIGHT_LIMIT = 15000; @Mock private RemoteWebDriver webDriver; @@ -136,21 +138,37 @@ public void collectTest_setOnlyHeight() throws ParametersException { tested.setParameters(params); } - @Test - public void collectTest_setOnlyWidth() throws ParametersException, ProcessingException { + private void setUp_setOnlyWidth(){ when(params.containsKey(WIDTH_PARAM)).thenReturn(true); when(params.containsKey(HEIGHT_PARAM)).thenReturn(false); when(params.get(WIDTH_PARAM)).thenReturn("" + CUSTOM_WIDTH); + } - when(capabilities.getBrowserName()).thenReturn("chrome"); - when(webDriver.executeScript("return document.body.scrollHeight")) - .thenReturn(CHROME_LIMIT + 5000L); + @Test + public void collectTest_setOnlyWidth() throws ParametersException, ProcessingException { + setUp_setOnlyWidth(); + when(webDriver.executeScript(JAVASCRIPT_GET_BODY_HEIGHT)) + .thenReturn(CUSTOM_HEIGHT); + + tested.setParameters(params); + tested.collect(); + + verify(windowDimension, never()).getWidth(); + verify(windowDimension, never()).getHeight(); + verify(window, atLeastOnce()).setSize(new Dimension(CUSTOM_WIDTH, CUSTOM_HEIGHT)); + } + + @Test + public void collectTest_setOnlyWidth_reachedBrowserHeightLimit() throws ParametersException, ProcessingException { + setUp_setOnlyWidth(); + when(webDriver.executeScript(JAVASCRIPT_GET_BODY_HEIGHT)) + .thenReturn(BROWSER_HEIGHT_LIMIT + 5000L); tested.setParameters(params); tested.collect(); verify(windowDimension, never()).getWidth(); verify(windowDimension, never()).getHeight(); - verify(window, atLeastOnce()).setSize(new Dimension(CUSTOM_WIDTH, CHROME_LIMIT)); + verify(window, atLeastOnce()).setSize(new Dimension(CUSTOM_WIDTH, BROWSER_HEIGHT_LIMIT)); } } From a85618f1dee16e49d84116d1de70850dad74d5fa Mon Sep 17 00:00:00 2001 From: Tomasz Kaik Date: Fri, 27 Jul 2018 13:45:19 +0200 Subject: [PATCH 19/29] Increased cookie max age for tests stabilization --- .../src/main/webapp/sanity/comparators/cookie/failed.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/sample-site/src/main/webapp/sanity/comparators/cookie/failed.jsp b/integration-tests/sample-site/src/main/webapp/sanity/comparators/cookie/failed.jsp index 04eee0921..5a48cff56 100644 --- a/integration-tests/sample-site/src/main/webapp/sanity/comparators/cookie/failed.jsp +++ b/integration-tests/sample-site/src/main/webapp/sanity/comparators/cookie/failed.jsp @@ -23,8 +23,8 @@ Cookie dynamicCookieValue = new Cookie("DynamicSampleCookieName",dt.format(date)); Cookie dynamicCookieName = new Cookie(dt.format(date),"staticCookieValue"); dynamicCookieValue.setMaxAge(60*60*24); - // expire cookie after 1 second in order to have it cleared for next run - dynamicCookieName.setMaxAge(10); + // expire cookie after 60 second in order to have it cleared for next run + dynamicCookieName.setMaxAge(60); response.addCookie( dynamicCookieValue ); response.addCookie( dynamicCookieName ); %> From b2e2e1db975898245b537f4b2c0e41da062fc7f4 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Tue, 31 Jul 2018 12:13:07 +0200 Subject: [PATCH 20/29] ResolutionModifier - refactor --- .../resolution/ResolutionModifier.java | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index e361673c9..78a31aa16 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -20,10 +20,7 @@ import com.cognifide.aet.job.api.collector.CollectorJob; import com.cognifide.aet.job.api.exceptions.ParametersException; import com.cognifide.aet.job.api.exceptions.ProcessingException; - import java.util.Map; -import java.util.Optional; - import org.apache.commons.lang3.math.NumberUtils; import org.openqa.selenium.Dimension; import org.openqa.selenium.JavascriptExecutor; @@ -48,11 +45,13 @@ public class ResolutionModifier implements CollectorJob { private static final int INITIAL_HEIGHT = 300; + private static final int HEIGHT_NOT_DEFINED = 0; + private final WebDriver webDriver; private int width; - private Optional height; + private int height; public ResolutionModifier(WebDriver webDriver) { this.webDriver = webDriver; @@ -71,11 +70,9 @@ public void setParameters(Map params) throws ParametersException width = NumberUtils.toInt(params.get(WIDTH_PARAM)); ParametersValidator.checkRange(width, 1, MAX_SIZE, "Width should be greater than 0"); if (params.containsKey(HEIGHT_PARAM)) { - height = Optional.of(NumberUtils.toInt(params.get(HEIGHT_PARAM))); + height = NumberUtils.toInt(params.get(HEIGHT_PARAM)); ParametersValidator - .checkRange(height.get(), 1, MAX_SIZE, "Height should be greater than 0"); - } else { - height = Optional.empty(); + .checkRange(height, 1, MAX_SIZE, "Height should be greater than 0"); } } else { throw new ParametersException("You have to specify width, height parameter is optional"); @@ -84,20 +81,17 @@ public void setParameters(Map params) throws ParametersException private void setResolution(WebDriver webDriver) { Window window = webDriver.manage().window(); - JavascriptExecutor js = (JavascriptExecutor) webDriver; - int localHeight; - if (height.isPresent()) { - localHeight = height.get(); - } else { + if (height == HEIGHT_NOT_DEFINED) { window.setSize(new Dimension(width, INITIAL_HEIGHT)); - localHeight = Integer + JavascriptExecutor js = (JavascriptExecutor) webDriver; + height = Integer .parseInt(js.executeScript(JAVASCRIPT_GET_BODY_HEIGHT).toString()); - if (localHeight > MAX_SIZE) { - LOG.info("Height is over browser limit, changing height to " + MAX_SIZE); - localHeight = MAX_SIZE; + if (height > MAX_SIZE) { + LOG.warn("Height is over browser limit, changing height to " + MAX_SIZE); + height = MAX_SIZE; } } - LOG.info("Setting resolution to {}x{} ", width, localHeight); - window.setSize(new Dimension(width, localHeight)); + LOG.info("Setting resolution to {}x{} ", width, height); + window.setSize(new Dimension(width, height)); } } From 2cafbda4a9f6834f5c5665c9c03c43bb2f6db467 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Tue, 31 Jul 2018 12:19:56 +0200 Subject: [PATCH 21/29] ResolutionModifierTest - update --- .../modifiers/resolution/ResolutionModifierTest.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java index d1b833c60..98b796f17 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifierTest.java @@ -15,10 +15,14 @@ */ package com.cognifide.aet.job.common.modifiers.resolution; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import com.cognifide.aet.job.api.exceptions.ParametersException; import com.cognifide.aet.job.api.exceptions.ProcessingException; import java.util.Map; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -30,8 +34,6 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; -import static org.mockito.Mockito.*; - @RunWith(MockitoJUnitRunner.class) public class ResolutionModifierTest { @@ -155,7 +157,7 @@ public void collectTest_setOnlyWidth() throws ParametersException, ProcessingExc verify(windowDimension, never()).getWidth(); verify(windowDimension, never()).getHeight(); - verify(window, atLeastOnce()).setSize(new Dimension(CUSTOM_WIDTH, CUSTOM_HEIGHT)); + verify(window, times(1)).setSize(new Dimension(CUSTOM_WIDTH, CUSTOM_HEIGHT)); } @Test @@ -169,6 +171,6 @@ public void collectTest_setOnlyWidth_reachedBrowserHeightLimit() throws Paramete verify(windowDimension, never()).getWidth(); verify(windowDimension, never()).getHeight(); - verify(window, atLeastOnce()).setSize(new Dimension(CUSTOM_WIDTH, BROWSER_HEIGHT_LIMIT)); + verify(window, times(1)).setSize(new Dimension(CUSTOM_WIDTH, BROWSER_HEIGHT_LIMIT)); } } From 80da189eb6d50f2fb3bccf5b2430788b17a4ee48 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Tue, 31 Jul 2018 12:24:14 +0200 Subject: [PATCH 22/29] ResolutionModifierTest - refactor --- .../aet/job/common/modifiers/resolution/ResolutionModifier.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index 78a31aa16..3cae930b7 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -87,7 +87,7 @@ private void setResolution(WebDriver webDriver) { height = Integer .parseInt(js.executeScript(JAVASCRIPT_GET_BODY_HEIGHT).toString()); if (height > MAX_SIZE) { - LOG.warn("Height is over browser limit, changing height to " + MAX_SIZE); + LOG.warn("Height is over browser limit, changing height to {}", MAX_SIZE); height = MAX_SIZE; } } From 5f5e26c7fb9749b8b08ee5339189e9ecdf1d1e0d Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Tue, 31 Jul 2018 14:35:02 +0200 Subject: [PATCH 23/29] Wiki - ResolutionModifier update --- documentation/src/main/wiki/ResolutionModifier.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/documentation/src/main/wiki/ResolutionModifier.md b/documentation/src/main/wiki/ResolutionModifier.md index e1b77a28d..a7e72bde3 100644 --- a/documentation/src/main/wiki/ResolutionModifier.md +++ b/documentation/src/main/wiki/ResolutionModifier.md @@ -1,10 +1,10 @@ #### Resolution Modifier -Resolution Modifier is responsible for changing browser screen size. Affects [[Screen Collector | ScreenCollector]] results. +Resolution Modifier is responsible for changing browser screen size. Affects [[Screen Collector | ScreenCollector]] results. | ! Note | |:------ | -| Please note that final resoulution of screenshots may be different when scrollbar is dispayed.

Default width of Firefox's Scrollbar is equal to 33px. (so when you want to grab viewport of size 1024, then set width parameter to 1057px) | +| Firefox: Please note that final resoulution of screenshots may be different when scrollbar is dispayed.

Default width of Firefox's Scrollbar is equal to 33px. (so when you want to grab viewport of size 1024, then set width parameter to 1057px) | Module name: **resolution** @@ -12,12 +12,11 @@ Module name: **resolution** | Parameter | Value | Description | Mandatory | | --------- | ----- | ----------- | --------- | -| `width` | int (1 to 100000) | Window width | no | -| `height` | int (1 to 100000) | Window height | no | +| `width` | int (1 to 15000) | Window width | yes | +| `height` | int (1 to 15000) | Window height | no | -| ! Important information | -|:----------------------- | -| You cannot maximize the window and specify the dimension at the same time. If you specify height param you have to also specify width param and vice versa. | +| Note | +| When height is not specified then it's compute by JavaScript.
If the resolution is specified without height parameter it should be specified after open. | ##### Example Usage From 0ae1f701dff30af3c95fe8debe3d2c3ef3c3d9a4 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Wed, 1 Aug 2018 09:40:51 +0200 Subject: [PATCH 24/29] layout.xml - new tests --- .../comparators/layout/height_detection.jsp | 29 ++++++++++++++++ .../test-suite/partials/layout.xml | 34 +++++++++++++++++-- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 integration-tests/sample-site/src/main/webapp/sanity/comparators/layout/height_detection.jsp diff --git a/integration-tests/sample-site/src/main/webapp/sanity/comparators/layout/height_detection.jsp b/integration-tests/sample-site/src/main/webapp/sanity/comparators/layout/height_detection.jsp new file mode 100644 index 000000000..65255b9f7 --- /dev/null +++ b/integration-tests/sample-site/src/main/webapp/sanity/comparators/layout/height_detection.jsp @@ -0,0 +1,29 @@ +<%-- + + AET + + Copyright (C) 2013 Cognifide Limited + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ include file="/includes/header.jsp" %> +<% +String timestamp = Long.toString(System.currentTimeMillis()); +%> +<%@ include file="/includes/bodyContent.jsp" %> +
+ <%@ include file="dynamic_content.jsp" %> +
+<%@ include file="/includes/footer.jsp" %> diff --git a/integration-tests/test-suite/partials/layout.xml b/integration-tests/test-suite/partials/layout.xml index 14ca62a8b..da32a7a66 100644 --- a/integration-tests/test-suite/partials/layout.xml +++ b/integration-tests/test-suite/partials/layout.xml @@ -67,7 +67,7 @@ - + @@ -84,7 +84,7 @@ - + @@ -152,5 +152,35 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 0af3bf312ab685cbe7771db20847955fd4bac3da Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Wed, 1 Aug 2018 09:48:45 +0200 Subject: [PATCH 25/29] height_detection.jsp - minor fix --- .../main/webapp/sanity/comparators/layout/height_detection.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/sample-site/src/main/webapp/sanity/comparators/layout/height_detection.jsp b/integration-tests/sample-site/src/main/webapp/sanity/comparators/layout/height_detection.jsp index 65255b9f7..a7c19495d 100644 --- a/integration-tests/sample-site/src/main/webapp/sanity/comparators/layout/height_detection.jsp +++ b/integration-tests/sample-site/src/main/webapp/sanity/comparators/layout/height_detection.jsp @@ -23,7 +23,7 @@ String timestamp = Long.toString(System.currentTimeMillis()); %> <%@ include file="/includes/bodyContent.jsp" %> -
+
<%@ include file="dynamic_content.jsp" %>
<%@ include file="/includes/footer.jsp" %> From 12e19a98bdeb6e62ffe1495a0c200dac7f26f807 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Wed, 1 Aug 2018 09:53:26 +0200 Subject: [PATCH 26/29] Wiki - ResolutionModifier update --- documentation/src/main/wiki/ResolutionModifier.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/src/main/wiki/ResolutionModifier.md b/documentation/src/main/wiki/ResolutionModifier.md index a7e72bde3..ad2483f80 100644 --- a/documentation/src/main/wiki/ResolutionModifier.md +++ b/documentation/src/main/wiki/ResolutionModifier.md @@ -16,7 +16,7 @@ Module name: **resolution** | `height` | int (1 to 15000) | Window height | no | | Note | -| When height is not specified then it's compute by JavaScript.
If the resolution is specified without height parameter it should be specified after open. | +| When height is not specified then it's computed by JavaScript.
If the resolution is specified without height parameter it should be specified after [`open`](https://github.com/Cognifide/aet/wiki/Open). | ##### Example Usage From 499442c3d396b5b114b60df1f7366526dbb94b32 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Wed, 1 Aug 2018 10:00:04 +0200 Subject: [PATCH 27/29] Wiki - HideModifier update --- documentation/src/main/wiki/HideModifier.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/src/main/wiki/HideModifier.md b/documentation/src/main/wiki/HideModifier.md index 9f57aa7f5..509a16cd0 100644 --- a/documentation/src/main/wiki/HideModifier.md +++ b/documentation/src/main/wiki/HideModifier.md @@ -7,7 +7,7 @@ Module name: **hide** | ! Important information | |:----------------------- | | *In order to use this modifier it must be declared after the open module in the definition of the test suite XML. -*In order to use this modifier with Resolution Modifier it must be declared before the Resolution Modifier.| +*In order to use this modifier with Resolution Modifier it must be declared before the Resolution Modifier because the Hide modifier might affect the total height of the page (when used without `leaveBlankSpace="true"`. | ##### Parameters From 864f783241d689fa835e8bc34635c7ba9aa3c188 Mon Sep 17 00:00:00 2001 From: Piotr Orleanski Date: Wed, 1 Aug 2018 13:23:28 +0200 Subject: [PATCH 28/29] ResolutionModifier update --- .../aet/job/common/modifiers/resolution/ResolutionModifier.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index 3cae930b7..ddb6352a1 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -72,7 +72,7 @@ public void setParameters(Map params) throws ParametersException if (params.containsKey(HEIGHT_PARAM)) { height = NumberUtils.toInt(params.get(HEIGHT_PARAM)); ParametersValidator - .checkRange(height, 1, MAX_SIZE, "Height should be greater than 0"); + .checkRange(height, 1, MAX_SIZE, "Height should be greater than 0 and smaller than " + MAX_SIZE); } } else { throw new ParametersException("You have to specify width, height parameter is optional"); From 0ba974fbdbff1faf1532d770d929198cad237bba Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Thu, 2 Aug 2018 10:03:26 +0200 Subject: [PATCH 29/29] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a0a8430b..4b8f2b61c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to AET will be documented in this file. ## Unreleased **List of changes that are finished but not yet released in any final version.** +- [PR-294](https://github.com/Cognifide/aet/pull/294) Added support for full page screenshot in chrome - [PR-271](https://github.com/Cognifide/aet/pull/271) Added possibility to override name parameter from the aet client - [PR-268](https://github.com/Cognifide/aet/pull/268) Bobcat upgrade to version 1.4.0 - [PR-279](https://github.com/Cognifide/aet/pull/279) Upgrade for some of libraries used by AET