From a2024dffd9b1825bbb472712c3acc0fcf4169fc0 Mon Sep 17 00:00:00 2001 From: Vitali Kepin Date: Wed, 18 Jan 2023 11:27:03 +0300 Subject: [PATCH] [extension-selenium] Unify syntax of steps changing context (#3517) --- .../plugins/pages/plugin-accessibility.adoc | 2 +- .../plugins/pages/plugin-mobile-app.adoc | 4 +- .../modules/plugins/pages/plugin-web-app.adoc | 2 +- .../partials/dynamic-variables-ui.adoc | 2 +- .../plugins/partials/generic-ui-steps.adoc | 22 +++++++--- .../partials/plugin-web-app-steps.adoc | 2 +- .../steps/ui/GenericSetContextSteps.java | 25 ++++++++++- .../resources/steps/defaults/deprecated.steps | 4 ++ .../steps/ui/GenericSetContextStepsTests.java | 42 ++++++++++++++++++- .../story/integration/ActionSteps.story | 8 ++-- .../story/integration/BarcodeStepsTests.story | 2 +- .../integration/CheckboxStepsTests.story | 4 +- .../story/integration/DragAndDropSteps.story | 2 +- .../integration/DynamicVariablesTests.story | 2 +- .../story/integration/ElementStepsTests.story | 6 +-- .../story/integration/LinkStepsTests.story | 2 +- .../story/integration/PageStepsTests.story | 2 +- .../story/integration/ProxyStepsTests.story | 2 +- .../story/integration/ScrollStepsTests.story | 20 ++++----- .../integration/SetContextStepsTests.story | 14 +++---- .../story/integration/SetVariableSteps.story | 8 ++-- .../story/integration/WindowSteps.story | 2 +- .../system/ApplitoolsVisualStepsTests.story | 10 ++--- .../story/system/VisualStepsTests.story | 38 ++++++++--------- .../mobile_app/MobileAppStepsTests.story | 14 +++---- .../system/mobile_app/VisualTesting.story | 6 +-- 26 files changed, 161 insertions(+), 86 deletions(-) diff --git a/docs/modules/plugins/pages/plugin-accessibility.adoc b/docs/modules/plugins/pages/plugin-accessibility.adoc index 6352e94e83..0462176f57 100644 --- a/docs/modules/plugins/pages/plugin-accessibility.adoc +++ b/docs/modules/plugins/pages/plugin-accessibility.adoc @@ -34,7 +34,7 @@ The step based on the contextual approach and when it's necessary it could be us [source,gherkin] ---- Given I am on page with URL `https://vividus-test-site.onrender.com/` -When I change context to element located `xpath(//body)` +When I change context to element located by `xpath(//body)` Then I test accessibility: |standard|level |elementsToIgnore |elementsToCheck|violationsToIgnore | |WCAG2AAA|NOTICE|By.id(ignore), By.cssSelector(#errors > h1 > img)| |WCAG2AAA.Principle1.Guideline1_3.1_3_1.H42.2,WCAG2AAA.Principle2.Guideline2_4.2_4_9.H30| diff --git a/docs/modules/plugins/pages/plugin-mobile-app.adoc b/docs/modules/plugins/pages/plugin-mobile-app.adoc index 36001746e4..e7784c6b66 100644 --- a/docs/modules/plugins/pages/plugin-mobile-app.adoc +++ b/docs/modules/plugins/pages/plugin-mobile-app.adoc @@ -831,7 +831,7 @@ Then number of elements found by `accessibilityId(end-of-screen)` is equal to `1 [source,gherkin] ---- Scenario: Switch slides -When I change context to element located `accessibilityId(carousel)` +When I change context to element located by `accessibilityId(carousel)` Then number of elements found by `accessibilityId(slide 2)` is equal to `0` When I swipe LEFT to element located `accessibilityId(slide 2)` with duration PT1S Then number of elements found by `accessibilityId(slide 2)` is equal to `1` @@ -1084,7 +1084,7 @@ When I scan barcode from context and save result to $scopes variable `$variableN .Scan the barcode [source,gherkin] ---- -When I change context to element located `xpath(//android.view.ViewGroup[@resource-id='qrContainer'])` +When I change context to element located by `xpath(//android.view.ViewGroup[@resource-id='qrContainer'])` When I scan barcode from context and save result to scenario variable `qrCodeLink` Then `${qrCodeLink}` is equal to `https://www.example.com` ---- diff --git a/docs/modules/plugins/pages/plugin-web-app.adoc b/docs/modules/plugins/pages/plugin-web-app.adoc index 41ac37b380..a045efa4b4 100644 --- a/docs/modules/plugins/pages/plugin-web-app.adoc +++ b/docs/modules/plugins/pages/plugin-web-app.adoc @@ -265,7 +265,7 @@ When I scan barcode from context and save result to $scopes variable `$variableN .Scan the barcode [source,gherkin] ---- -When I change context to element located `By.xpath(//div[@id='qrCode'])` +When I change context to element located by `xpath(//div[@id='qrCode'])` When I scan barcode from context and save result to scenario variable `qrCodeLink` Then `${qrCodeLink}` is equal to `https://www.example.com` ---- diff --git a/docs/modules/plugins/partials/dynamic-variables-ui.adoc b/docs/modules/plugins/partials/dynamic-variables-ui.adoc index e529b1dda5..7f44a67913 100644 --- a/docs/modules/plugins/partials/dynamic-variables-ui.adoc +++ b/docs/modules/plugins/partials/dynamic-variables-ui.adoc @@ -33,7 +33,7 @@ WARNING: In case of missing search context the error will be logged and `-1` wil .Check the size and the location of the image [source,gherkin] ---- -When I change context to element located `id(userpic)` +When I change context to element located by `id(userpic)` Then `${context-height}` is > `0` Then `${context-width}` is > `0` Then `${context-x-coordinate}` is > `0` diff --git a/docs/modules/plugins/partials/generic-ui-steps.adoc b/docs/modules/plugins/partials/generic-ui-steps.adoc index d59ae6be31..ebf9e918ac 100644 --- a/docs/modules/plugins/partials/generic-ui-steps.adoc +++ b/docs/modules/plugins/partials/generic-ui-steps.adoc @@ -148,7 +148,7 @@ When I save text of context element to $scopes variable `$variableName` .Save the text of the context element [source,gherkin] ---- -When I change context to element located `By.id(username)` +When I change context to element located by `id(username)` When I save text of context element to SCENARIO variable `username` ---- @@ -172,7 +172,7 @@ When I save `$attributeName` attribute value of context element to $scopes varia .Save the attribute value of the context element [source,gherkin] ---- -When I change context to element located `By.id(username)` +When I change context to element located by `id(username)` When I save `innerText` attribute value of context element to SCENARIO variable `username` ---- @@ -223,6 +223,12 @@ Then `${numberOfLinks}` is equal to `1` Changes the context to an element located by locator for limiting area of subsequent UI interactions. +[source,gherkin] +---- +When I change context to element located by `$locator` in scope of current context +---- + +_Deprecated syntax (will be removed in VIVIDUS 0.7.0)_: [source,gherkin] ---- When I change context to element located `$locator` in scope of current context @@ -234,7 +240,7 @@ When I change context to element located `$locator` in scope of current context [source,gherkin] ---- Then number of elements found by `By.xpath(html)` is equal to `1` -When I change context to element located `By.xpath(//body)` in scope of current context +When I change context to element located by `xpath(//body)` in scope of current context Then number of elements found by `By.xpath(html)` is equal to `0` ---- @@ -242,6 +248,12 @@ Then number of elements found by `By.xpath(html)` is equal to `0` Resets current context and changes the context to an element located by locator for limiting area of subsequent UI interactions. +[source,gherkin] +---- +When I change context to element located by `$locator` +---- + +_Deprecated syntax (will be removed in VIVIDUS 0.7.0)_: [source,gherkin] ---- When I change context to element located `$locator` @@ -253,7 +265,7 @@ When I change context to element located `$locator` [source,gherkin] ---- Then number of elements found by `By.xpath(html)` is equal to `1` -When I change context to element located `By.xpath(//body)` +When I change context to element located by `xpath(//body)` Then number of elements found by `By.xpath(html)` is equal to `0` ---- @@ -271,7 +283,7 @@ When I reset context [source,gherkin] ---- Then number of elements found by `By.xpath(html)` is equal to `1` -When I change context to element located `By.xpath(//body)` +When I change context to element located by `xpath(//body)` Then number of elements found by `By.xpath(html)` is equal to `0` When I reset context Then number of elements found by `By.xpath(html)` is equal to `1` diff --git a/docs/modules/plugins/partials/plugin-web-app-steps.adoc b/docs/modules/plugins/partials/plugin-web-app-steps.adoc index f8ea83ce47..908f675184 100644 --- a/docs/modules/plugins/partials/plugin-web-app-steps.adoc +++ b/docs/modules/plugins/partials/plugin-web-app-steps.adoc @@ -160,7 +160,7 @@ If the context is not set, the whole page will be scrolled .Scroll login to a bottom [source,gherkin] ---- -When I change context to element located `id(login)` +When I change context to element located by `id(login)` When I scroll context to BOTTOM edge ---- diff --git a/vividus-extension-selenium/src/main/java/org/vividus/steps/ui/GenericSetContextSteps.java b/vividus-extension-selenium/src/main/java/org/vividus/steps/ui/GenericSetContextSteps.java index 53418076b2..ee1a4c84a0 100644 --- a/vividus-extension-selenium/src/main/java/org/vividus/steps/ui/GenericSetContextSteps.java +++ b/vividus-extension-selenium/src/main/java/org/vividus/steps/ui/GenericSetContextSteps.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 the original author or authors. + * Copyright 2019-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,8 @@ import org.jbehave.core.annotations.When; import org.openqa.selenium.WebElement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.vividus.steps.ui.validation.IBaseValidations; import org.vividus.ui.action.search.Locator; import org.vividus.ui.context.IUiContext; @@ -30,6 +32,7 @@ public class GenericSetContextSteps { public static final String ELEMENT_TO_SET_CONTEXT = "Element to set context"; + private static final Logger LOGGER = LoggerFactory.getLogger(GenericSetContextSteps.class); private final IUiContext uiContext; private final IBaseValidations baseValidations; @@ -52,21 +55,39 @@ public void resetContext() * Resets currently set context and * sets the context for further localization of elements to an element located by locator * @param locator locator to find an element + * @deprecated Use step: "When I change context to element located by `$locator`" */ + @Deprecated(since = "0.5.4", forRemoval = true) @When("I change context to element located `$locator`") public void resetAndChangeContextToElement(Locator locator) { + LOGGER.warn("The step: \"When I change context to element located `$locator`\" is deprecated " + + "and will be removed in VIVIDUS 0.7.0. " + + "Use step: \"When I change context to element located by `$locator`\""); resetContext(); changeContext(() -> getBaseValidations().assertIfElementExists(ELEMENT_TO_SET_CONTEXT, locator), () -> resetAndChangeContextToElement(locator)); } + /** + * Resets currently set context and + * sets the context for further localization of elements to an element located by locator + * @param locator locator to find an element + */ + @When("I change context to element located by `$locator`") + public void resetAndSetContextToElement(Locator locator) + { + resetContext(); + changeContext(() -> getBaseValidations().assertElementExists(ELEMENT_TO_SET_CONTEXT, locator).orElse(null), + () -> resetAndSetContextToElement(locator)); + } + /** * Sets the context for further localization of elements to an element located by locator * in scope of the current context. * @param locator locator to find an element */ - @When("I change context to element located `$locator` in scope of current context") + @When("I change context to element located by `$locator` in scope of current context") public void changeContextToElement(Locator locator) { changeContext(() -> getBaseValidations().assertElementExists(ELEMENT_TO_SET_CONTEXT, locator).orElse(null), diff --git a/vividus-extension-selenium/src/main/resources/steps/defaults/deprecated.steps b/vividus-extension-selenium/src/main/resources/steps/defaults/deprecated.steps index 352a5e1691..ba80a2dabc 100644 --- a/vividus-extension-selenium/src/main/resources/steps/defaults/deprecated.steps +++ b/vividus-extension-selenium/src/main/resources/steps/defaults/deprecated.steps @@ -9,3 +9,7 @@ When I wait until element located by `` disappears Composite: Then element located `$locator` exists for `$duration` duration !-- WARNING: The step "Then element located `$locator` exists for `$duration` duration" is deprecated and will be removed in VIVIDUS 0.6.0 Then element located by `` exists for `` duration + +Composite: When I change context to element located `$locator` in scope of current context +!-- WARNING: The step "When I change context to element located `$locator` in scope of current context` duration" is deprecated and will be removed in VIVIDUS 0.7.0 +When I change context to element located by `` in scope of current context diff --git a/vividus-extension-selenium/src/test/java/org/vividus/steps/ui/GenericSetContextStepsTests.java b/vividus-extension-selenium/src/test/java/org/vividus/steps/ui/GenericSetContextStepsTests.java index b31b9d8617..d3d6d66dc1 100644 --- a/vividus-extension-selenium/src/test/java/org/vividus/steps/ui/GenericSetContextStepsTests.java +++ b/vividus-extension-selenium/src/test/java/org/vividus/steps/ui/GenericSetContextStepsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 the original author or authors. + * Copyright 2019-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,9 @@ package org.vividus.steps.ui; +import static com.github.valfirst.slf4jtest.LoggingEvent.warn; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; @@ -26,8 +29,14 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; +import java.util.List; import java.util.Optional; +import com.github.valfirst.slf4jtest.LoggingEvent; +import com.github.valfirst.slf4jtest.TestLogger; +import com.github.valfirst.slf4jtest.TestLoggerFactory; +import com.github.valfirst.slf4jtest.TestLoggerFactoryExtension; + import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -42,11 +51,13 @@ import org.vividus.ui.context.IUiContext; import org.vividus.ui.context.SearchContextSetter; -@ExtendWith(MockitoExtension.class) +@ExtendWith({ MockitoExtension.class, TestLoggerFactoryExtension.class }) class GenericSetContextStepsTests { private static final String ELEMENT_TO_SET_CONTEXT = "Element to set context"; + private final TestLogger logger = TestLoggerFactory.getTestLogger(GenericSetContextSteps.class); + @Mock private IUiContext uiContext; @Mock private IBaseValidations baseValidations; @InjectMocks private GenericSetContextSteps genericSetContextSteps; @@ -83,6 +94,33 @@ void shouldResetAndChangeContextToElement() verify(uiContext, times(2)).reset(); verify(uiContext, times(2)).putSearchContext(eq(webElement), any(SearchContextSetter.class)); verify(baseValidations, times(2)).assertIfElementExists(ELEMENT_TO_SET_CONTEXT, locator); + LoggingEvent expectedLoggingEvent = warn( + "The step: \"When I change context to element located `$locator`\" is deprecated " + + "and will be removed in VIVIDUS 0.7.0. " + + "Use step: \"When I change context to element located by `$locator`\""); + assertThat(logger.getLoggingEvents(), is(List.of(expectedLoggingEvent, expectedLoggingEvent))); + } + + @Test + void shouldResetAndSetContextToElement() + { + Locator locator = mock(Locator.class); + WebElement webElement = mock(WebElement.class); + Optional webElementOpt = Optional.of(webElement); + GenericSetContextSteps spy = Mockito.spy(genericSetContextSteps); + ArgumentCaptor setterCaptor = ArgumentCaptor.forClass(SearchContextSetter.class); + + when(baseValidations.assertElementExists(ELEMENT_TO_SET_CONTEXT, locator)).thenReturn(webElementOpt); + doNothing().when(uiContext).putSearchContext(eq(webElement), setterCaptor.capture()); + + spy.resetAndSetContextToElement(locator); + + SearchContextSetter setter = setterCaptor.getValue(); + setter.setSearchContext(); + verify(spy, times(2)).resetAndSetContextToElement(locator); + verify(uiContext, times(2)).reset(); + verify(uiContext, times(2)).putSearchContext(eq(webElement), any(SearchContextSetter.class)); + verify(baseValidations, times(2)).assertElementExists(ELEMENT_TO_SET_CONTEXT, locator); } @Test diff --git a/vividus-tests/src/main/resources/story/integration/ActionSteps.story b/vividus-tests/src/main/resources/story/integration/ActionSteps.story index e6a52c7ac3..ffc1601b45 100644 --- a/vividus-tests/src/main/resources/story/integration/ActionSteps.story +++ b/vividus-tests/src/main/resources/story/integration/ActionSteps.story @@ -44,7 +44,7 @@ Then the text '${expectedText}' exists Scenario: Action verification CLICK_AND_HOLD Given I am on page with URL `${vividus-test-site-url}/mouseEvents.html` -When I change context to element located `By.id(target)` +When I change context to element located by `id(target)` Then the context element has the CSS property 'background-color'='rgba(255, 255, 255, 1)' When I execute sequence of actions: |type |argument | @@ -53,7 +53,7 @@ Then the context element has the CSS property 'background-color'='rgba(255, 0, 0 Scenario: Action verification CLICK_AND_HOLD with no argument Given I am on page with URL `${vividus-test-site-url}/mouseEvents.html` -When I change context to element located `By.id(target)` +When I change context to element located by `id(target)` Then the context element has the CSS property 'background-color'='rgba(255, 255, 255, 1)' When I execute sequence of actions: |type |argument | @@ -63,7 +63,7 @@ Then the context element has the CSS property 'background-color'='rgba(255, 0, 0 Scenario: Action verification RELEASE Given I am on page with URL `${vividus-test-site-url}/mouseEvents.html` -When I change context to element located `By.id(target)` +When I change context to element located by `id(target)` Then the context element has the CSS property 'background-color'='rgba(255, 255, 255, 1)' When I execute sequence of actions: |type |argument | @@ -73,7 +73,7 @@ Then the context element has the CSS property 'background-color'='rgba(0, 128, 0 Scenario: Action verification RELEASE with no argument Given I am on page with URL `${vividus-test-site-url}/mouseEvents.html` -When I change context to element located `By.id(target)` +When I change context to element located by `id(target)` Then the context element has the CSS property 'background-color'='rgba(255, 255, 255, 1)' When I execute sequence of actions: |type |argument | diff --git a/vividus-tests/src/main/resources/story/integration/BarcodeStepsTests.story b/vividus-tests/src/main/resources/story/integration/BarcodeStepsTests.story index bd6a9980d3..df1f3ccba7 100644 --- a/vividus-tests/src/main/resources/story/integration/BarcodeStepsTests.story +++ b/vividus-tests/src/main/resources/story/integration/BarcodeStepsTests.story @@ -12,6 +12,6 @@ Meta: @requirementId 2687 Given I am on page with URL `${vividus-test-site-url}/qrModal.html` When I click on element located by `id(modalButton)` -When I change context to element located `By.xpath(//div[@class='modal-content'])` in scope of current context +When I change context to element located by `xpath(//div[@class='modal-content'])` in scope of current context When I scan barcode from context and save result to scenario variable `qrCodeLink` Then `${qrCodeLink}` is = `https://github.com/vividus-framework/vividus` diff --git a/vividus-tests/src/main/resources/story/integration/CheckboxStepsTests.story b/vividus-tests/src/main/resources/story/integration/CheckboxStepsTests.story index 281df17d8c..c00a116be4 100644 --- a/vividus-tests/src/main/resources/story/integration/CheckboxStepsTests.story +++ b/vividus-tests/src/main/resources/story/integration/CheckboxStepsTests.story @@ -9,14 +9,14 @@ Scope: STORY Given I am on page with URL `${vividus-test-site-url}/checkboxes.html` Scenario: Validation of step: 'When I $checkboxAction checkbox located by `$searchAttributes`' -When I change context to element located `id(single)` +When I change context to element located by `id(single)` Then number of not selected elements found by `checkboxName(One)` is equal to `1` When I check checkbox located by `id(one)` Then number of selected elements found by `checkboxName(One)` is equal to `1` When I refresh the page Scenario: Validation of step 'When I $checkboxState all checkboxes located by `$checkboxesLocator`' -When I change context to element located `id(double)` +When I change context to element located by `id(double)` Then number of not selected elements found by `checkboxName(Two)` is equal to `1` Then number of not selected elements found by `checkboxName(Three)` is equal to `1` When I check all checkboxes located by `xpath(.//input)` diff --git a/vividus-tests/src/main/resources/story/integration/DragAndDropSteps.story b/vividus-tests/src/main/resources/story/integration/DragAndDropSteps.story index 08c72770d0..08785a9a5b 100644 --- a/vividus-tests/src/main/resources/story/integration/DragAndDropSteps.story +++ b/vividus-tests/src/main/resources/story/integration/DragAndDropSteps.story @@ -4,7 +4,7 @@ Meta: Scenario: Step verification 'When I drag element located `$origin` and drop it at $location of element located `$target`' Given I am on page with URL `https://4qp6vjp319.codesandbox.io/` When I wait until element located by `xpath(//div[@id='root']/ul)` appears -When I change context to element located `By.xpath(//div[@id='root']/ul)` +When I change context to element located by `xpath(//div[@id='root']/ul)` Then the text matches 'item 0.*item 1.*item 2.*item 3.*' When I drag element located `By.xpath(//li[contains(., 'item 0')])` and drop it at top of element located `By.xpath(//li[contains(., 'item 3')])` Then the text matches 'item 1.*item 2.*item 0.*item 3.*' diff --git a/vividus-tests/src/main/resources/story/integration/DynamicVariablesTests.story b/vividus-tests/src/main/resources/story/integration/DynamicVariablesTests.story index 2cce794768..0509e1da6f 100644 --- a/vividus-tests/src/main/resources/story/integration/DynamicVariablesTests.story +++ b/vividus-tests/src/main/resources/story/integration/DynamicVariablesTests.story @@ -13,7 +13,7 @@ Given I am on page with URL `${vividus-test-site-url}` Scenario: Verify context' rectangle dynamic variables Meta: @requirementId 802 -When I change context to element located `tagName(img)` +When I change context to element located by `tagName(img)` Then `${context-height}` is > `0` Then `${context-width}` is > `0` Then `${context-x-coordinate}` is > `0` diff --git a/vividus-tests/src/main/resources/story/integration/ElementStepsTests.story b/vividus-tests/src/main/resources/story/integration/ElementStepsTests.story index b480f241b3..7c7d9e3681 100644 --- a/vividus-tests/src/main/resources/story/integration/ElementStepsTests.story +++ b/vividus-tests/src/main/resources/story/integration/ElementStepsTests.story @@ -43,7 +43,7 @@ Then the page has the relative URL '/mouseEvents.html' Scenario: Step verification Then the context element has a width of '$widthInPerc'% relative to the parent element Given I am on page with URL `${vividus-test-site-url}/dropdowns.html` -When I change context to element located `By.xpath(.//*[@for='colors'])` +When I change context to element located by `xpath(.//*[@for='colors'])` Then the context element has a width of '13'% relative to the parent element Scenario: Step verification When I perform right click on an element located `$locator` @@ -56,12 +56,12 @@ Then number of elements found by `elementName(Bar)` is = `1` Scenario: Step verification Then the context element has the CSS property '$cssName'='$cssValue' Given I am on page with URL `${vividus-test-site-url}/inputs.html` -When I change context to element located `By.xpath(.//*[@title='Text input section'])` +When I change context to element located by `xpath(.//*[@title='Text input section'])` Then the context element has the CSS property 'color'='rgba(0, 0, 0, 1)' Scenario: Step verification Then the context element has the CSS property '$cssName' containing '$cssValue' Given I am on page with URL `${vividus-test-site-url}/inputs.html` -When I change context to element located `By.xpath(.//*[@title='Text input section'])` +When I change context to element located by `xpath(.//*[@title='Text input section'])` Then the context element has the CSS property 'color' containing '(0, 0, 0, 1)' Scenario: Step verification When I select an element '$locator' and upload the file '$filePath' diff --git a/vividus-tests/src/main/resources/story/integration/LinkStepsTests.story b/vividus-tests/src/main/resources/story/integration/LinkStepsTests.story index b29e4f605d..343467ed87 100644 --- a/vividus-tests/src/main/resources/story/integration/LinkStepsTests.story +++ b/vividus-tests/src/main/resources/story/integration/LinkStepsTests.story @@ -9,7 +9,7 @@ Examples: Scenario: Step verification Then context contains list of link items with the text: $expectedLinkItems Given I am on page with URL `` -When I change context to element located `By.xpath(//body)` +When I change context to element located by `xpath(//body)` Then context contains list of link items with the text: |text | |Link to an element| diff --git a/vividus-tests/src/main/resources/story/integration/PageStepsTests.story b/vividus-tests/src/main/resources/story/integration/PageStepsTests.story index 998a006dc0..8b13897978 100644 --- a/vividus-tests/src/main/resources/story/integration/PageStepsTests.story +++ b/vividus-tests/src/main/resources/story/integration/PageStepsTests.story @@ -17,7 +17,7 @@ Meta: When I open URL `${vividus-test-site-url}/delayedLoading?imageTimeout=1000` in new window When I stop page loading When I execute async javascript `setTimeout(() => arguments[0]('wait for page to load'), 1000)` and save result to scenario variable `timeout` -When I change context to element located `cssSelector(img)` +When I change context to element located by `cssSelector(img)` Then `${context-height}` is < `100` Then `${context-width}` is < `100` diff --git a/vividus-tests/src/main/resources/story/integration/ProxyStepsTests.story b/vividus-tests/src/main/resources/story/integration/ProxyStepsTests.story index 39785ab049..26500d9642 100644 --- a/vividus-tests/src/main/resources/story/integration/ProxyStepsTests.story +++ b/vividus-tests/src/main/resources/story/integration/ProxyStepsTests.story @@ -55,7 +55,7 @@ When I add headers to proxied requests with URL pattern which is equal to `http: |testName1|testValue1| |testName2|testValue2| Given I am on page with URL `http://httpbin.org/headers` -When I change context to element located `xpath(//pre)` +When I change context to element located by `xpath(//pre)` When I set the text found in search context to the 'SCENARIO' variable 'response' Then JSON element from `${response}` by JSON path `$.headers` is equal to ` { diff --git a/vividus-tests/src/main/resources/story/integration/ScrollStepsTests.story b/vividus-tests/src/main/resources/story/integration/ScrollStepsTests.story index 4c1412532d..6edc04cf31 100644 --- a/vividus-tests/src/main/resources/story/integration/ScrollStepsTests.story +++ b/vividus-tests/src/main/resources/story/integration/ScrollStepsTests.story @@ -3,28 +3,28 @@ Meta: Scenario: Scroll RIGHT for element Verify step: When I scroll context to $scrollDirection edge Given I am on page with URL `${vividus-test-site-url}/scrollableElements.html` -When I change context to element located `By.id(scrollable)` +When I change context to element located by `id(scrollable)` When I scroll context to RIGHT edge -When I change context to element located `By.id(current-horizontal):a` +When I change context to element located by `id(current-horizontal):a` Then the text matches '\d+' Scenario: Scroll LEFT for element Verify step: When I scroll context to $scrollDirection edge -When I change context to element located `By.id(scrollable)` +When I change context to element located by `id(scrollable)` When I scroll context to LEFT edge -When I change context to element located `By.id(current-horizontal):a` +When I change context to element located by `id(current-horizontal):a` Then the text matches '0' Scenario: Scroll BOTTOM for element Verify step: When I scroll context to $scrollDirection edge -When I change context to element located `By.id(current-vertical):a` -When I change context to element located `By.id(scrollable)` +When I change context to element located by `id(current-vertical):a` +When I change context to element located by `id(scrollable)` When I scroll context to BOTTOM edge -When I change context to element located `By.id(current-vertical):a` +When I change context to element located by `id(current-vertical):a` Then the text matches '\d+' Scenario: Scroll TOP for element Verify step: When I scroll context to $scrollDirection edge -When I change context to element located `By.id(scrollable)` +When I change context to element located by `id(scrollable)` When I scroll context to TOP edge -When I change context to element located `By.id(current-vertical):a` +When I change context to element located by `id(current-vertical):a` Then the text matches '0' Scenario: Verify step: When I scroll element located `$locator` into view @@ -32,7 +32,7 @@ Meta: @requirementId 436 When I refresh the page When I scroll element located `xpath(//a[text()="Contact"])` into view -When I change context to element located `By.id(current-vertical):a` +When I change context to element located by `id(current-vertical):a` Then the text matches '\d+' Scenario: Scroll BOTTOM for page Verify step: When I scroll context to $scrollDirection edge diff --git a/vividus-tests/src/main/resources/story/integration/SetContextStepsTests.story b/vividus-tests/src/main/resources/story/integration/SetContextStepsTests.story index 2330ddc4da..9496780829 100644 --- a/vividus-tests/src/main/resources/story/integration/SetContextStepsTests.story +++ b/vividus-tests/src/main/resources/story/integration/SetContextStepsTests.story @@ -41,7 +41,7 @@ Then the page title is equal to '' Scenario: Verify step: "When I switch to frame located `$locator`" Given I am on page with URL `${vividus-test-site-url}/nestedFrames.html` -When I change context to element located `id(toRemove):a` +When I change context to element located by `id(toRemove):a` When I execute javascript ` document.querySelector('#toRemove').remove(); return []; @@ -51,23 +51,23 @@ When I switch to frame located `id(exampleCom)` When I click on element located by `xpath(//a)` -Scenario: Verify steps: "When I reset context" AND "When I change context to element located `$locator`" -When I change context to element located `By.xpath(//body)` +Scenario: Verify steps: "When I reset context" AND "When I change context to element located by `$locator`" +When I change context to element located by `xpath(//body)` Then number of elements found by `By.xpath(html)` is equal to `0` When I reset context Then number of elements found by `By.xpath(html)` is equal to `1` -Scenario: Verify step: "When I change context to element located `$locator` in scope of current context" +Scenario: Verify step: "When I change context to element located by `$locator` in scope of current context" Given I am on page with URL `${vividus-test-site-url}` -When I change context to element located `xpath(//a)` +When I change context to element located by `xpath(//a)` When I change context to element located `xpath(.//*)` in scope of current context When I save `name` attribute value of context element to scenario variable `name` Then `${name}` is = `vividus-logo` Scenario: Verify step: "When I reset context" -When I change context to element located `By.xpath(//body)` +When I change context to element located by `xpath(//body)` Then number of elements found by `By.xpath(html)` is equal to `0` When I reset context Then number of elements found by `By.xpath(html)` is equal to `1` @@ -85,7 +85,7 @@ Then number of elements found by `id(modalButton)` is equal to `1` Scenario: Verify context healing Given I am on page with URL `${vividus-test-site-url}` -When I change context to element located `tagName(a)` +When I change context to element located by `tagName(a)` When I execute javascript `location.reload();` with arguments: Then number of elements found by `cssSelector(img)` is = `1` diff --git a/vividus-tests/src/main/resources/story/integration/SetVariableSteps.story b/vividus-tests/src/main/resources/story/integration/SetVariableSteps.story index 1bb8045ba5..b188ec8651 100644 --- a/vividus-tests/src/main/resources/story/integration/SetVariableSteps.story +++ b/vividus-tests/src/main/resources/story/integration/SetVariableSteps.story @@ -4,14 +4,14 @@ Meta: Scenario: Verify step: "When I set the text found in search context to the '$scopes' variable '$variableName'" Given I am on page with URL `${vividus-test-site-url}/inputs.html` When I enter `text` in field located `By.id(text)` -When I change context to element located `By.id(output)` +When I change context to element located by `id(output)` When I set the text found in search context to the 'SCENARIO' variable 'variableName' Then `text` is equal to `${variableName}` When I reset context Scenario: Verify step: "When I set '$attributeName' attribute value of the context element to the '$scopes' variable '$variableName'" -When I change context to element located `By.id(text)` +When I change context to element located by `id(text)` When I set 'name' attribute value of the context element to the 'SCENARIO' variable 'variableName' Then `text` is equal to `${variableName}` When I reset context @@ -24,14 +24,14 @@ Then `text` is equal to `${variableName}` Scenario: Verify step: "When I save text of context element to $scopes variable `$variableName`" When I enter `text` in field located `By.id(text)` -When I change context to element located `By.id(output)` +When I change context to element located by `id(output)` When I save text of context element to SCENARIO variable `variableName` Then `text` is equal to `${variableName}` When I reset context Scenario: Verify step: "When I save `$attributeName` attribute value of context element to $scopes variable `$variableName`" -When I change context to element located `By.id(text)` +When I change context to element located by `id(text)` When I save `name` attribute value of context element to SCENARIO variable `variableName` Then `text` is equal to `${variableName}` When I reset context diff --git a/vividus-tests/src/main/resources/story/integration/WindowSteps.story b/vividus-tests/src/main/resources/story/integration/WindowSteps.story index 2ad22532c6..e2eb1a6c81 100644 --- a/vividus-tests/src/main/resources/story/integration/WindowSteps.story +++ b/vividus-tests/src/main/resources/story/integration/WindowSteps.story @@ -3,7 +3,7 @@ Meta: Scenario: Validation of step When I change window size to `$sizeAsString` Given I am on page with URL `${vividus-test-site-url}/stickyHeader.html` -When I change context to element located `id(myHeader)` +When I change context to element located by `id(myHeader)` Then `${context-width}` is `` When I change window size to `x` Then `${context-width}` is <= `` diff --git a/vividus-tests/src/main/resources/story/system/ApplitoolsVisualStepsTests.story b/vividus-tests/src/main/resources/story/system/ApplitoolsVisualStepsTests.story index 981e9cc45c..4568c6d26a 100644 --- a/vividus-tests/src/main/resources/story/system/ApplitoolsVisualStepsTests.story +++ b/vividus-tests/src/main/resources/story/system/ApplitoolsVisualStepsTests.story @@ -9,7 +9,7 @@ Scope: STORY Given I am on page with URL `${vividus-test-site-url}/stickyHeader.html` Examples: |action |firstP |batchName | -|COMPARE_AGAINST|By.xpath((.//p)[1])|Vividus System Tests| +|COMPARE_AGAINST|xpath((.//p)[1]) |Vividus System Tests| Scenario: Validation of step: 'When I $actionType baseline `$testName` in batch `$batchName` with Applitools' for full page @@ -17,11 +17,11 @@ When I baseline `full-page` in batch `` with Applitools Scenario: Validation of step: 'When I $actionType baseline `$testName` in batch `$batchName` with Applitools' for context element -When I change context to element located `` +When I change context to element located by `` When I baseline `context` in batch `` with Applitools Scenario: Validation of CHECK_INEQUALITY_AGAINST action -When I change context to element located `` +When I change context to element located by `` When I CHECK_INEQUALITY_AGAINST baseline `full-page` in batch `` with Applitools Scenario: Validation of step: 'When I run visual test with Applitools using:$applitoolsConfigurations' for full page with element cut @@ -38,14 +38,14 @@ When I run visual test with Applitools using: Scenario: Validation of step: 'When I run visual test with Applitools using:$applitoolsConfigurations' for context element with element cut -When I change context to element located `By.xpath(.//body)` +When I change context to element located by `xpath(.//body)` When I run visual test with Applitools using: |baselineName |batchName |action |elementsToIgnore| |context-element-cut ||| | Scenario: Validation of step: 'When I run visual test with Applitools using:$applitoolsConfigurations' for context element not in viewport with element cut -When I change context to element located `By.xpath(.//p[last()])` +When I change context to element located by `xpath(.//p[last()])` When I run visual test with Applitools using: |baselineName |batchName |action |elementsToIgnore | |not-viewport-context-element-cut |||By.cssSelector(img)| diff --git a/vividus-tests/src/main/resources/story/system/VisualStepsTests.story b/vividus-tests/src/main/resources/story/system/VisualStepsTests.story index c8d8059429..71a595dfb6 100644 --- a/vividus-tests/src/main/resources/story/system/VisualStepsTests.story +++ b/vividus-tests/src/main/resources/story/system/VisualStepsTests.story @@ -9,7 +9,7 @@ Scope: STORY Given I am on page with URL `${vividus-test-site-url}/stickyHeader.html` Examples: |action |firstP | -|COMPARE_AGAINST|By.xpath((.//p)[1])| +|COMPARE_AGAINST|xpath((.//p)[1])| Scenario: Validation of step When I $actionType baseline with name `$name` for full page @@ -18,19 +18,19 @@ When I baseline with name `full-page` using storage `filesystem` Scenario: Validation of step When I $actionType baseline with name `$name` for context element -When I change context to element located `` +When I change context to element located by `` When I baseline with name `context` When I reset context Scenario: Validation of CHECK_INEQUALITY_AGAINST action -When I change context to element located `` +When I change context to element located by `` When I CHECK_INEQUALITY_AGAINST baseline with name `full-page` When I reset context Scenario: Validation of CHECK_INEQUALITY_AGAINST action with step level parameters -When I change context to element located `` +When I change context to element located by `` When I CHECK_INEQUALITY_AGAINST baseline with name `full-page` ignoring: |REQUIRED_DIFF_PERCENTAGE| |85 | @@ -53,31 +53,31 @@ When I baseline with name `full-page-area-cut` ignoring: Scenario: Validation of step "When I $actionType baseline with name `$name` ignoring:$checkSettings" for context element with element cut -When I change context to element located `By.xpath(.//body)` +When I change context to element located by `xpath(.//body)` When I baseline with name `context-element-cut` ignoring: |ELEMENT | || Scenario: Validation of step "When I $actionType baseline with `$name` ignoring:$checkSettings" for context element not in viewport with element cut -When I change context to element located `By.xpath(.//p[last()])` +When I change context to element located by `xpath(.//p[last()])` When I baseline with name `not-viewport-context-element-cut` ignoring: |ELEMENT | -|By.cssSelector(img)| +|cssSelector(img)| Scenario: Validation of step When I $actionType baseline with name `$name` for full page with element/area cut When I reset context When I baseline with name `full-page-with-scroll-element-area-cut` ignoring: -|ELEMENT |AREA | -|By.xpath(//p[position() mod 2 = 1 and position() > 10])|By.xpath(//p[position() mod 2 = 1 and position() < 10])| +|ELEMENT |AREA | +|xpath(//p[position() mod 2 = 1 and position() > 10])|xpath(//p[position() mod 2 = 1 and position() < 10])| Scenario: Validation of cut for whole page and context When I baseline with name `cuts-full-page` using screenshot configuration: |cutTop |cutBottom |cutLeft|cutRight|webHeaderToCut| |1200 |1300 |600 |1000 |100 | -When I change context to element located `` +When I change context to element located by `` When I baseline with name `cuts-context` using screenshot configuration: |cutTop|cutBottom|cutLeft|cutRight| |50 |60 |800 |1000 | @@ -87,29 +87,29 @@ Scenario: Validation of contextual visual testing on a page with scrollable elem Given I am on page with URL `${vividus-test-site-url}/visualTestIntegration.html` When I baseline with name `scrollable-element-context` using screenshot configuration: |scrollableElement|webHeaderToCut|webFooterToCut|scrollTimeout| -|By.id(scrollable)|10 |0 |PT1S | +|id(scrollable) |10 |0 |PT1S | When I baseline with name `scrollable-element-context` using storage `filesystem` and screenshot configuration: |scrollableElement|webHeaderToCut|webFooterToCut|scrollTimeout| -|By.id(scrollable)|10 |0 |PT1S | +|id(scrollable) |10 |0 |PT1S | Scenario: Validation of full-page visual testing on a page with scrollable element with ignores When I baseline with name `scrollable-element-fullpage-with-ignores` ignoring: -|ELEMENT |AREA | -|By.xpath(//a[position() mod 2 = 1 and position() > 7])|By.xpath(//a[position() mod 2 = 1 and position() < 7])| +|ELEMENT |AREA | +|xpath(//a[position() mod 2 = 1 and position() > 7])|xpath(//a[position() mod 2 = 1 and position() < 7])| using screenshot configuration: |scrollableElement|webHeaderToCut|webFooterToCut|scrollTimeout| -|By.id(scrollable)|10 |0 |PT1S | +|id(scrollable) |10 |0 |PT1S | When I baseline with name `scrollable-element-fullpage-with-ignores` using storage `filesystem` and ignoring: -|ELEMENT |AREA | -|By.xpath(//a[position() mod 2 = 1 and position() > 7])|By.xpath(//a[position() mod 2 = 1 and position() < 7])| +|ELEMENT |AREA | +|xpath(//a[position() mod 2 = 1 and position() > 7])|xpath(//a[position() mod 2 = 1 and position() < 7])| and screenshot configuration: |scrollableElement|webHeaderToCut|webFooterToCut|scrollTimeout| -|By.id(scrollable)|10 |0 |PT1S | +|id(scrollable) |10 |0 |PT1S | Scenario: Validation of step When I $actionType baseline with name `$name` for context element with acceptable diff percentage -When I change context to element located `By.xpath(//a[@href="#home"])` +When I change context to element located by `xpath(//a[@href="#home"])` When I baseline with name `context-element-with-acceptable-diff-percentage` ignoring: |ACCEPTABLE_DIFF_PERCENTAGE| |5 | diff --git a/vividus-tests/src/main/resources/story/system/mobile_app/MobileAppStepsTests.story b/vividus-tests/src/main/resources/story/system/mobile_app/MobileAppStepsTests.story index 65c7c6d9d4..8097413086 100644 --- a/vividus-tests/src/main/resources/story/system/mobile_app/MobileAppStepsTests.story +++ b/vividus-tests/src/main/resources/story/system/mobile_app/MobileAppStepsTests.story @@ -30,7 +30,7 @@ When I wait until element located by `xpath()->filter.text(Hom Scenario: Validate coordinate/size dynamic variables, page source dynamic variable Then `${source-code}` matches `.+Home.+` -When I change context to element located `xpath()->filter.text(Home)` +When I change context to element located by `xpath()->filter.text(Home)` Then `${context-height}` is > `0` Then `${context-width}` is > `0` Then `${context-x-coordinate}` is > `0` @@ -103,11 +103,11 @@ Then number of elements found by `accessibilityId(increment)->filter.attribute($ Scenario: Verify step: 'When I double tap on element located by `$locator`' -When I change context to element located `accessibilityId(incrementDisplay)` +When I change context to element located by `accessibilityId(incrementDisplay)` When I save text of context element to scenario variable `incrementTextBefore` When I reset context When I double tap on element located by `accessibilityId(increment)` -When I change context to element located `accessibilityId(incrementDisplay)` +When I change context to element located by `accessibilityId(incrementDisplay)` When I save text of context element to scenario variable `incrementTextAfter` When I reset context Given I initialize scenario variable `countBefore` with value `#{replaceFirstByRegExp(Count: (\d+), $1, ${incrementTextBefore})}` @@ -304,7 +304,7 @@ Meta: @targetPlatform ios When I tap on element located by `accessibilityId(menuToggler)` When I tap on element located by `xpath(//XCUIElementTypeButton[@name="Date Picker"])` -When I change context to element located `accessibilityId(dateTimePicker)` +When I change context to element located by `accessibilityId(dateTimePicker)` When I select next value with `0.1` offset in picker wheel located `xpath(//XCUIElementTypePickerWheel)->filter.index(1)` When I select previous value with `0.1` offset in picker wheel located `xpath(//XCUIElementTypePickerWheel)->filter.index(2)` When I select next value with `0.1` offset in picker wheel located `xpath(//XCUIElementTypePickerWheel)->filter.index(3)` @@ -334,7 +334,7 @@ Then number of elements found by `accessibilityId()` When I swipe RIGHT to element located by `accessibilityId()` with duration PT1S Then number of elements found by `accessibilityId()` is = `1` Then number of elements found by `accessibilityId()` is = `0` -When I change context to element located `xpath()` +When I change context to element located by `xpath()` When I swipe LEFT to element located by `accessibilityId()` with duration PT1S Then number of elements found by `accessibilityId()` is = `0` Then number of elements found by `accessibilityId()` is = `1` @@ -362,7 +362,7 @@ Then number of elements found by `accessibilityId()` Scenario: Verify step: 'When I execute javascript `$script` with arguments:$args' on Android Meta: @targetPlatform android -When I change context to element located `xpath(//android.view.ViewGroup[./android.widget.TextView[@content-desc=""]])` +When I change context to element located by `xpath(//android.view.ViewGroup[./android.widget.TextView[@content-desc=""]])` Given I initialize scenario variable `x` with value `${context-x-coordinate}` Given I initialize scenario variable `y` with value `${context-y-coordinate}` Given I initialize scenario variable `width` with value `${context-width}` @@ -392,7 +392,7 @@ Then `${qrCodeLink}` is = `https://github.com/vividus-framework/vividus` Scenario: Verify steps: "When I scan barcode from context and save result to $scopes variable `$variableName`" Meta: @requirementId 2687 -When I change context to element located `xpath()` +When I change context to element located by `xpath()` When I scan barcode from context and save result to scenario variable `qrCodeLink` Then `${qrCodeLink}` is = `https://github.com/vividus-framework/vividus` When I reset context diff --git a/vividus-tests/src/main/resources/story/system/mobile_app/VisualTesting.story b/vividus-tests/src/main/resources/story/system/mobile_app/VisualTesting.story index 4ed1d9bee4..1c14eff6ef 100644 --- a/vividus-tests/src/main/resources/story/system/mobile_app/VisualTesting.story +++ b/vividus-tests/src/main/resources/story/system/mobile_app/VisualTesting.story @@ -45,14 +45,14 @@ Scenario: Verify cuts for full-page and context When I baseline with name `${target-platform}-cuts-full-page` using screenshot configuration: |cutTop|cutBottom|cutLeft|cutRight| |400 |300 |200 |100 | -When I change context to element located `${element-to-ignore}` +When I change context to element located by `${element-to-ignore}` When I baseline with name `${target-platform}-cuts-context` using screenshot configuration: |cutTop|cutBottom|cutLeft|cutRight| |400 |200 |100 |200 | Scenario: Step verification: When I $actionType baseline with name `$name` for the context -When I change context to element located `${element-to-ignore}` +When I change context to element located by `${element-to-ignore}` When I baseline with name `${target-platform}-context` When I reset context @@ -92,7 +92,7 @@ Scenario: Verify contextual check with ignored element When I tap on element located `accessibilityId(menuToggler)` When I tap on element located `xpath()` When I wait until element located by `xpath()` appears -When I change context to element located `xpath()` +When I change context to element located by `xpath()` When I baseline with name `${target-platform}-context-with-ignore` ignoring: |ELEMENT | |By.accessibilityId(header)|