diff --git a/docs/modules/plugins/partials/applitools-configuration.adoc b/docs/modules/plugins/partials/applitools-configuration.adoc index f988c15d7b..f0f60ab021 100644 --- a/docs/modules/plugins/partials/applitools-configuration.adoc +++ b/docs/modules/plugins/partials/applitools-configuration.adoc @@ -19,3 +19,4 @@ ** `accessibilityStandard` - The accessibility standard to check the page against. The required value format is ` - `, where standard is either `WCAG 2.0` or `WCAG 2.1` and level is either `AA` or `AAA`. This check uses {contrast-advisor} that helps in identifying potential contrast violations in both the text and images of your web and mobile applications, helping to ensure your technology is more accessible. Please *make sure* {contrast-advisor} feature is enabled in your Applitools account. ** `disableBrowserFetching` - By default, is `false`. If `true`, page resources for rendering on the UFG will be fetched from outside of the browser. ** `layoutBreakpoints` - By default, is `true`. If `true`, the viewport width and height are changed to the specified device's values prior to capturing the page source for rendering in UFG. +** `scaleRatio` - The scale ratio of the image, the less the ratio the smaller the image and vice versa, for example if we want to make the image 25% smaller the ration should be set to `0.75`, this can be useful if image height exceeds the Applitools height limit (15000 pixels). diff --git a/vividus-plugin-applitools/src/main/java/org/vividus/visual/eyes/converter/ExamplesTableToApplitoolsVisualChecksConverter.java b/vividus-plugin-applitools/src/main/java/org/vividus/visual/eyes/converter/ExamplesTableToApplitoolsVisualChecksConverter.java index 6ab7a9a2a6..a05a7ca552 100644 --- a/vividus-plugin-applitools/src/main/java/org/vividus/visual/eyes/converter/ExamplesTableToApplitoolsVisualChecksConverter.java +++ b/vividus-plugin-applitools/src/main/java/org/vividus/visual/eyes/converter/ExamplesTableToApplitoolsVisualChecksConverter.java @@ -63,12 +63,13 @@ public class ExamplesTableToApplitoolsVisualChecksConverter extends private static final String ELEMENTS_TO_IGNORE_OPTION = "elementsToIgnore"; private static final String AREAS_TO_IGNORE_OPTION = "areasToIgnore"; private static final String ACCESSIBILITY_STANDARD_OPTION = "accessibilityStandard"; + private static final String SCALE_RATIO = "scaleRatio"; private static final List SUPPORTED_OPTIONS = List.of(BASELINE_NAME_OPTION, ACTION_OPTION, EXECUTE_API_KEY_OPTION, READ_API_KEY_OPTION, HOST_APP_OPTION, HOST_OS_OPTION, VIEWPORT_SIZE_OPTION, MATCH_LEVEL_OPTION, DISABLE_BROWSER_FETCHING, SERVER_URI_OPTION, APP_NAME_OPTION, BATCH_NAME_OPTION, BASELINE_ENV_NAME_OPTION, ELEMENTS_TO_IGNORE_OPTION, AREAS_TO_IGNORE_OPTION, ACCESSIBILITY_STANDARD_OPTION, - LAYOUT_BREAKPOINTS); + LAYOUT_BREAKPOINTS, SCALE_RATIO); private String executeApiKey; private String readApiKey; @@ -128,7 +129,8 @@ public List convertValue(ExamplesTable table, Type type) params.valueAs(READ_API_KEY_OPTION, String.class, readApiKey), params.valueAs(ELEMENTS_TO_IGNORE_OPTION, targetType, Set.of()), params.valueAs(AREAS_TO_IGNORE_OPTION, targetType, Set.of()), - params.valueAs(ACCESSIBILITY_STANDARD_OPTION, AccessibilitySettings.class, null) + params.valueAs(ACCESSIBILITY_STANDARD_OPTION, AccessibilitySettings.class, null), + params.valueAs(SCALE_RATIO, Double.class, null) ); return check; @@ -140,7 +142,7 @@ public ApplitoolsVisualCheck create(String batchName, String baselineName, Visua { ApplitoolsVisualCheck check = createCheck(batchName, baselineName, action); configureEyes(check, executeApiKey, hostApp, hostOS, viewportSize, matchLevel, disableBrowserFetching, - layoutBreakpoints, serverUri, appName, baselineEnvName, readApiKey, Set.of(), Set.of(), null); + layoutBreakpoints, serverUri, appName, baselineEnvName, readApiKey, Set.of(), Set.of(), null, null); return check; } @@ -153,7 +155,7 @@ private ApplitoolsVisualCheck createCheck(String batchName, String baselineName, private void configureEyes(ApplitoolsVisualCheck check, String executeApiKey, String hostApp, String hostOS, Dimension viewportSize, MatchLevel matchLevel, Boolean disableBrowserFetching, Boolean layoutBreakpoints, URI serverUri, String appName, String baselineEnvName, String readApiKey, Set elements, - Set areas, AccessibilitySettings settings) + Set areas, AccessibilitySettings settings, Double scaleRatio) { check.setScreenshotParameters(screenshotParametersFactory.create()); check.setReadApiKey(readApiKey); @@ -175,7 +177,8 @@ private void configureEyes(ApplitoolsVisualCheck check, String executeApiKey, St .setServerUrl(Optional.ofNullable(serverUri).map(URI::toString).orElse(null)) .setAppName(appName) .setBaselineEnvName(baselineEnvName) - .setAccessibilityValidation(settings); + .setAccessibilityValidation(settings) + .setScaleRatio(scaleRatio); boolean saveTests = check.getAction() == VisualActionType.ESTABLISH; configuration.setSaveFailedTests(saveTests); diff --git a/vividus-plugin-applitools/src/test/java/org/vividus/visual/eyes/converter/ExamplesTableToApplitoolsVisualChecksConverterTests.java b/vividus-plugin-applitools/src/test/java/org/vividus/visual/eyes/converter/ExamplesTableToApplitoolsVisualChecksConverterTests.java index f5e484cf6c..4270efc448 100644 --- a/vividus-plugin-applitools/src/test/java/org/vividus/visual/eyes/converter/ExamplesTableToApplitoolsVisualChecksConverterTests.java +++ b/vividus-plugin-applitools/src/test/java/org/vividus/visual/eyes/converter/ExamplesTableToApplitoolsVisualChecksConverterTests.java @@ -83,8 +83,8 @@ void shouldConvertExamplesTableIntoApplitoolsVisualChecksAllParameters() when(baselineIndexer.createIndexedBaseline(BASELINE)).thenReturn(BASELINE); // CHECKSTYLE:OFF - String table = "|executeApiKey |readApiKey |hostApp |hostOS |viewportSize|matchLevel|disableBrowserFetching|layoutBreakpoints|serverUri |appName |batchName |baselineEnvName |elementsToIgnore|areasToIgnore|baselineName |action |accessibilityStandard|" + System.lineSeparator() - + "|execute-api-key|read-api-key|host-app|host-os|1x1 |EXACT |true |true |https://example.com|app-name|batch-name|baseline-env-name|elements |areas |baseline-name|ESTABLISH|WCAG 2.1 - AA |"; + String table = "|executeApiKey |readApiKey |hostApp |hostOS |viewportSize|matchLevel|disableBrowserFetching|layoutBreakpoints|serverUri |appName |batchName |baselineEnvName |elementsToIgnore|areasToIgnore|baselineName |action |accessibilityStandard|scaleRatio|" + System.lineSeparator() + + "|execute-api-key|read-api-key|host-app|host-os|1x1 |EXACT |true |true |https://example.com|app-name|batch-name|baseline-env-name|elements |areas |baseline-name|ESTABLISH|WCAG 2.1 - AA |0.75 |"; // CHECKSTYLE:ON ExamplesTable applitoolsCheckTable = createTable(table); @@ -114,6 +114,7 @@ void shouldConvertExamplesTableIntoApplitoolsVisualChecksAllParameters() () -> assertTrue(configuration.isDisableBrowserFetching()), () -> assertTrue(configuration.isDefaultLayoutBreakpointsSet()), () -> assertEquals(BATCH, configuration.getBatch().getName()), + () -> assertEquals(0.75d, configuration.getScaleRatio()), () -> assertEquals(AccessibilityLevel.AA, settings.getLevel()), () -> assertEquals(AccessibilityGuidelinesVersion.WCAG_2_1, settings.getGuidelinesVersion()) ); @@ -184,7 +185,8 @@ private void testDefaultParameters(Supplier> checksS () -> assertFalse(configuration.isDisableBrowserFetching()), () -> assertFalse(configuration.isDefaultLayoutBreakpointsSet()), () -> assertEquals(BATCH, configuration.getBatch().getName()), - () -> assertNull(configuration.getAccessibilityValidation()) + () -> assertNull(configuration.getAccessibilityValidation()), + () -> assertNull(configuration.getScaleRatio()) ); } diff --git a/vividus-tests/src/main/resources/story/system/ApplitoolsVisualStepsTests.story b/vividus-tests/src/main/resources/story/system/ApplitoolsVisualStepsTests.story index 4568c6d26a..85e948bdbc 100644 --- a/vividus-tests/src/main/resources/story/system/ApplitoolsVisualStepsTests.story +++ b/vividus-tests/src/main/resources/story/system/ApplitoolsVisualStepsTests.story @@ -12,6 +12,12 @@ Examples: |COMPARE_AGAINST|xpath((.//p)[1]) |Vividus System Tests| +Scenario: Scaling validation +When I run visual test with Applitools using: +|baselineName |batchName |action |scaleRatio| +|full-page-scaling|||0.75 | + + Scenario: Validation of step: 'When I $actionType baseline `$testName` in batch `$batchName` with Applitools' for full page When I baseline `full-page` in batch `` with Applitools