diff options
Diffstat (limited to 'integration-tests')
16 files changed, 150 insertions, 283 deletions
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/SetupCDTest.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/SetupCDTest.java index e595cc372d..c3afc0bd13 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/SetupCDTest.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/SetupCDTest.java @@ -124,7 +124,7 @@ public abstract class SetupCDTest extends DriverFactory { return HAR_FILES_FOLDER; } - protected UserRoleEnum getRole(){ + protected UserRoleEnum getRole() { return UserRoleEnum.DESIGNER; } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHeaderComponent.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHeaderComponent.java index cb2fcc261f..2afd0e2333 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHeaderComponent.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHeaderComponent.java @@ -19,15 +19,13 @@ package org.onap.sdc.frontend.ci.tests.pages; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; -import static org.onap.sdc.frontend.ci.tests.pages.OnboardHeaderComponent.XpathSelector.MAIN_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.OnboardHeaderComponent.XpathSelector.ONBOARD_TAB_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.OnboardHeaderComponent.XpathSelector.WORKSPACE_TAB_DIV; - /** * Handles the Onboard Header Component UI test actions */ @@ -42,47 +40,40 @@ public class OnboardHeaderComponent extends AbstractPageObject { @Override public void isLoaded() { wrappingElement = getWait() - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(MAIN_DIV.getXpath()))); + .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.MAIN_DIV.getXpath()))); getWait() - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(WORKSPACE_TAB_DIV.getXpath()))); + .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.WORKSPACE_TAB_DIV.getXpath()))); getWait() - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(ONBOARD_TAB_DIV.getXpath()))); + .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.ONBOARD_TAB_DIV.getXpath()))); } /** * Clicks on the workspace tab. */ public void clickOnWorkspaceTab() { - wrappingElement.findElement(By.xpath(WORKSPACE_TAB_DIV.getXpath())); + wrappingElement.findElement(By.xpath(XpathSelector.WORKSPACE_TAB_DIV.getXpath())); } /** * Clicks on the workspace tab. */ public void clickOnOnboardTab() { - wrappingElement.findElement(By.xpath(ONBOARD_TAB_DIV.getXpath())); + wrappingElement.findElement(By.xpath(XpathSelector.ONBOARD_TAB_DIV.getXpath())); } /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ - public enum XpathSelector { + @AllArgsConstructor + private enum XpathSelector { MAIN_DIV("onboard-header", "//div[contains(@class, '%s')]"), WORKSPACE_TAB_DIV("onboard-workspace-tab", "//div[@data-test-id='%s']"), ONBOARD_TAB_DIV("onboard-onboard-tab", "//div[@data-test-id='%s']"); + @Getter private final String id; private final String xpathFormat; - XpathSelector(final String id, final String xpathFormat) { - this.id = id; - this.xpathFormat = xpathFormat; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpathFormat, id); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHomePage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHomePage.java index 5b47233a5c..cd3e34d36e 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHomePage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/OnboardHomePage.java @@ -19,14 +19,13 @@ package org.onap.sdc.frontend.ci.tests.pages; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; -import static org.onap.sdc.frontend.ci.tests.pages.OnboardHomePage.XpathSelector.ADD_NEW_VLM_BTN; -import static org.onap.sdc.frontend.ci.tests.pages.OnboardHomePage.XpathSelector.ADD_NEW_VSP_BTN; - /** * Handles the Onboard Home Page UI test actions */ @@ -45,9 +44,9 @@ public class OnboardHomePage extends AbstractPageObject { public void isLoaded() { onboardHeaderComponent.isLoaded(); createNewVspBtn = getWait() - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(ADD_NEW_VSP_BTN.getXpath()))); + .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.ADD_NEW_VSP_BTN.getXpath()))); getWait() - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(ADD_NEW_VLM_BTN.getXpath()))); + .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.ADD_NEW_VLM_BTN.getXpath()))); } /** @@ -63,22 +62,15 @@ public class OnboardHomePage extends AbstractPageObject { /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ - public enum XpathSelector { + @AllArgsConstructor + private enum XpathSelector { ADD_NEW_VSP_BTN("catalog-add-new-vsp", "//div[@data-test-id='%s']"), ADD_NEW_VLM_BTN("catalog-add-new-vlm", "//div[@data-test-id='%s']"); + @Getter private final String id; private final String xpathFormat; - XpathSelector(final String id, final String xpathFormat) { - this.id = id; - this.xpathFormat = xpathFormat; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpathFormat, id); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java index b856a13de0..bb4ccb9b6d 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java @@ -19,6 +19,12 @@ package org.onap.sdc.frontend.ci.tests.pages; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalToIgnoringCase; +import static org.hamcrest.core.Is.is; + +import lombok.AllArgsConstructor; +import lombok.Getter; import org.onap.sdc.frontend.ci.tests.datatypes.LifeCycleStateEnum; import org.onap.sdc.frontend.ci.tests.utilities.LoaderHelper; import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent; @@ -30,11 +36,6 @@ import org.openqa.selenium.support.ui.ExpectedConditions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalToIgnoringCase; -import static org.hamcrest.core.Is.is; -import static org.onap.sdc.frontend.ci.tests.pages.ResourceCreatePage.XpathSelector.FORM_LIFE_CYCLE_STATE; - /** * Handles the Resource Create Page UI actions */ @@ -55,8 +56,8 @@ public class ResourceCreatePage extends AbstractPageObject { @Override public void isLoaded() { - LOGGER.debug("Waiting for element visibility with xpath '{}'", FORM_LIFE_CYCLE_STATE.getXpath()); - final WebElement lifeCycleState = waitForElementVisibility(FORM_LIFE_CYCLE_STATE.getXpath()); + LOGGER.debug("Waiting for element visibility with xpath '{}'", XpathSelector.FORM_LIFE_CYCLE_STATE.getXpath()); + final WebElement lifeCycleState = waitForElementVisibility(XpathSelector.FORM_LIFE_CYCLE_STATE.getXpath()); assertThat("Life cycle state should be as expected", lifeCycleState.getText(), is(equalToIgnoringCase(LifeCycleStateEnum.IN_DESIGN.getValue()))); createBtn = getWait() @@ -75,22 +76,15 @@ public class ResourceCreatePage extends AbstractPageObject { /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ - public enum XpathSelector { + @AllArgsConstructor + private enum XpathSelector { CREATE_BTN("create/save", "//button[@data-tests-id='%s']"), FORM_LIFE_CYCLE_STATE("formlifecyclestate", "//span[@data-tests-id='%s']"); + @Getter private final String id; private final String xpathFormat; - XpathSelector(final String id, final String xpathFormat) { - this.id = id; - this.xpathFormat = xpathFormat; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpathFormat, id); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceLeftSideMenu.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceLeftSideMenu.java index 03df126f00..b58a3adc8a 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceLeftSideMenu.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceLeftSideMenu.java @@ -19,17 +19,14 @@ package org.onap.sdc.frontend.ci.tests.pages; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; -import static org.onap.sdc.frontend.ci.tests.pages.ResourceLeftSideMenu.XpathSelector.GENERAL_MENU; -import static org.onap.sdc.frontend.ci.tests.pages.ResourceLeftSideMenu.XpathSelector.MAIN_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.ResourceLeftSideMenu.XpathSelector.PROPERTIES_ASSIGNMENT_MENU; -import static org.onap.sdc.frontend.ci.tests.pages.ResourceLeftSideMenu.XpathSelector.TOSCA_ARTIFACTS_MENU; - /** * Handles the Resource Page Left Side Menu UI actions */ @@ -54,7 +51,7 @@ public class ResourceLeftSideMenu extends AbstractPageObject { */ public WebElement getWrappingElement() { return getWait() - .until(ExpectedConditions.visibilityOfElementLocated(By.className(MAIN_DIV.getId()))); + .until(ExpectedConditions.visibilityOfElementLocated(By.className(XpathSelector.MAIN_DIV.getId()))); } /** @@ -63,7 +60,7 @@ public class ResourceLeftSideMenu extends AbstractPageObject { * @return the next page object */ public ResourcePropertiesAssignmentPage clickOnPropertiesAssignmentMenuItem() { - wrappingElement.findElement(By.xpath(PROPERTIES_ASSIGNMENT_MENU.getXpath())).click(); + wrappingElement.findElement(By.xpath(XpathSelector.PROPERTIES_ASSIGNMENT_MENU.getXpath())).click(); return new ResourcePropertiesAssignmentPage(webDriver); } @@ -73,7 +70,7 @@ public class ResourceLeftSideMenu extends AbstractPageObject { * @return the next page object */ public ToscaArtifactsPage clickOnToscaArtifactsMenuItem() { - wrappingElement.findElement(By.xpath(TOSCA_ARTIFACTS_MENU.getXpath())).click(); + wrappingElement.findElement(By.xpath(XpathSelector.TOSCA_ARTIFACTS_MENU.getXpath())).click(); return new ToscaArtifactsPage(webDriver); } @@ -83,31 +80,24 @@ public class ResourceLeftSideMenu extends AbstractPageObject { * @return the next page object */ public ServiceCreatePage clickOnGeneralMenuItem() { - wrappingElement.findElement(By.xpath(GENERAL_MENU.getXpath())).click(); + wrappingElement.findElement(By.xpath(XpathSelector.GENERAL_MENU.getXpath())).click(); return new ServiceCreatePage(webDriver); } /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ - public enum XpathSelector { + @AllArgsConstructor + private enum XpathSelector { MAIN_DIV("w-sdc-left-sidebar", "//div[@class='%s']"), PROPERTIES_ASSIGNMENT_MENU("Properties AssignmentLeftSideMenu", "//*[@data-tests-id='%s']"), GENERAL_MENU("GeneralLeftSideMenu", "//*[@data-tests-id='%s']"), TOSCA_ARTIFACTS_MENU("TOSCA ArtifactsLeftSideMenu", "//*[@data-tests-id='%s']"); + @Getter private final String id; private final String xpathFormat; - XpathSelector(final String id, final String xpathFormat) { - this.id = id; - this.xpathFormat = xpathFormat; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpathFormat, id); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java index bf99e03f9f..9cb104d67e 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java @@ -20,15 +20,6 @@ package org.onap.sdc.frontend.ci.tests.pages; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.INPUT_PROPERTY; -import static org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.MAIN_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.NO_DATA_MESSAGE; -import static org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.PROPERTIES_TABLE; -import static org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.PROPERTY_CHECKBOX; -import static org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.PROPERTY_SAVE_BTN; -import static org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.SOFTWARE_VERSION_INPUT; -import static org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.SOFTWARE_VERSION_PROPERTY_CHECKBOX; -import static org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.TITLE_DIV; import java.util.ArrayList; import java.util.List; @@ -60,9 +51,9 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject { @Override public void isLoaded() { wrappingElement = getWait(5) - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(MAIN_DIV.getXpath()))); + .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.MAIN_DIV.getXpath()))); getWait(5) - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(TITLE_DIV.getXpath()))); + .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.TITLE_DIV.getXpath()))); } /** @@ -72,11 +63,11 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject { */ public List<String> getSoftwareVersionProperty() { waitPropertiesToLoad(); - final By swVersionCheckboxLocator = By.xpath(SOFTWARE_VERSION_PROPERTY_CHECKBOX.getXpath()); + final By swVersionCheckboxLocator = By.xpath(XpathSelector.SOFTWARE_VERSION_PROPERTY_CHECKBOX.getXpath()); waitForElementVisibility(swVersionCheckboxLocator, 5); final List<String> softwareVersionList = new ArrayList<>(); - final List<WebElement> elements = wrappingElement.findElements(By.xpath(SOFTWARE_VERSION_INPUT.getXpath())); + final List<WebElement> elements = wrappingElement.findElements(By.xpath(XpathSelector.SOFTWARE_VERSION_INPUT.getXpath())); for (final WebElement element : elements) { softwareVersionList.add(element.getAttribute("value")); } @@ -91,10 +82,10 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject { */ public String getStringPropertyValue(final String propertyName) { waitPropertiesToLoad(); - final By propertyCheckboxLocator = By.xpath(PROPERTY_CHECKBOX.getXpath(propertyName)); + final By propertyCheckboxLocator = By.xpath(XpathSelector.PROPERTY_CHECKBOX.getXpath(propertyName)); final WebElement propertyCheckbox = waitForElementVisibility(propertyCheckboxLocator, 5); final WebElement propertyRow = propertyCheckbox.findElement(By.xpath("./../../..")); - final WebElement propertyInput = propertyRow.findElement(By.xpath(INPUT_PROPERTY.getXpath(propertyName))); + final WebElement propertyInput = propertyRow.findElement(By.xpath(XpathSelector.INPUT_PROPERTY.getXpath(propertyName))); return propertyInput.getAttribute("value"); } @@ -106,10 +97,10 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject { return; } waitPropertiesToLoad(); - final By propertyCheckboxLocator = By.xpath(PROPERTY_CHECKBOX.getXpath(propertyName)); + final By propertyCheckboxLocator = By.xpath(XpathSelector.PROPERTY_CHECKBOX.getXpath(propertyName)); final WebElement propertyCheckbox = waitForElementVisibility(propertyCheckboxLocator, 5); final WebElement propertyRow = propertyCheckbox.findElement(By.xpath("./../../..")); - final WebElement propertyInput = propertyRow.findElement(By.xpath(INPUT_PROPERTY.getXpath(propertyName))); + final WebElement propertyInput = propertyRow.findElement(By.xpath(XpathSelector.INPUT_PROPERTY.getXpath(propertyName))); propertyInput.sendKeys(value); } @@ -144,7 +135,7 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject { public boolean isPropertyPresent(final String propertyName) { waitPropertiesToLoad(); try { - waitForElementVisibility(By.xpath(PROPERTY_CHECKBOX.getXpath(propertyName)), 5); + waitForElementVisibility(By.xpath(XpathSelector.PROPERTY_CHECKBOX.getXpath(propertyName)), 5); } catch (final Exception ignored) { return false; } @@ -155,12 +146,12 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject { * Waits for the properties loading. */ private void waitPropertiesToLoad() { - waitForElementVisibility(By.xpath(PROPERTIES_TABLE.getXpath()), 5); - waitForElementInvisibility(By.xpath(NO_DATA_MESSAGE.getXpath()), 5); + waitForElementVisibility(By.xpath(XpathSelector.PROPERTIES_TABLE.getXpath()), 5); + waitForElementInvisibility(By.xpath(XpathSelector.NO_DATA_MESSAGE.getXpath()), 5); } public void saveProperties() { - final WebElement saveBtn = waitForElementVisibility(By.xpath(PROPERTY_SAVE_BTN.getXpath())); + final WebElement saveBtn = waitForElementVisibility(By.xpath(XpathSelector.PROPERTY_SAVE_BTN.getXpath())); assertTrue(saveBtn.isEnabled(), "Property save button should be enabled."); saveBtn.click(); loaderHelper.waitForLoader(20); @@ -171,7 +162,7 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject { * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ @AllArgsConstructor - public enum XpathSelector { + private enum XpathSelector { MAIN_DIV("w-sdc-main-right-container", "//div[@class='%s']"), TITLE_DIV("tab-title", "//div[contains(@class,'%s') and contains(text(), 'Properties Assignment')]"), PROPERTIES_TABLE("properties-table", "//div[contains(@class,'%s')]"), diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceWorkspaceTopBarComponent.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceWorkspaceTopBarComponent.java index 70d068f972..f92069e687 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceWorkspaceTopBarComponent.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceWorkspaceTopBarComponent.java @@ -19,13 +19,6 @@ package org.onap.sdc.frontend.ci.tests.pages; -import static org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent.XpathSelector.FORM_LIFE_CYCLE_STATE; -import static org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent.XpathSelector.ACTION_BUTTON_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent.XpathSelector.LIFECYCLE_STATE_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent.XpathSelector.MAIN_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent.XpathSelector.VERSION_CONTAINER_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.ServiceCreatePage.XpathSelector.CREATE_BTN; - import lombok.AllArgsConstructor; import lombok.Getter; import org.openqa.selenium.By; @@ -52,26 +45,26 @@ public class ResourceWorkspaceTopBarComponent extends AbstractPageObject { @Override public void isLoaded() { - LOGGER.debug("Waiting for element visibility with xpath '{}'", MAIN_DIV.getXpath()); - wrappingElement = waitForElementVisibility(By.xpath(MAIN_DIV.getXpath()), 5); - lifecycleStateDiv = wrappingElement.findElement(By.xpath(LIFECYCLE_STATE_DIV.getXpath())); - versionContainerDiv = wrappingElement.findElement(By.xpath(VERSION_CONTAINER_DIV.getXpath())); - actionButtonsDiv = wrappingElement.findElement(By.xpath(ACTION_BUTTON_DIV.getXpath())); + LOGGER.debug("Waiting for element visibility with xpath '{}'", XpathSelector.MAIN_DIV.getXpath()); + wrappingElement = waitForElementVisibility(By.xpath(XpathSelector.MAIN_DIV.getXpath()), 5); + lifecycleStateDiv = wrappingElement.findElement(By.xpath(XpathSelector.LIFECYCLE_STATE_DIV.getXpath())); + versionContainerDiv = wrappingElement.findElement(By.xpath(XpathSelector.VERSION_CONTAINER_DIV.getXpath())); + actionButtonsDiv = wrappingElement.findElement(By.xpath(XpathSelector.ACTION_BUTTON_DIV.getXpath())); } public void clickOnCreate() { - waitToBeClickable(CREATE_BTN.getXpath()).click(); + waitToBeClickable(XpathSelector.CREATE_BTN.getXpath()).click(); } public String getLifecycleState() { - return lifecycleStateDiv.findElement(By.xpath(FORM_LIFE_CYCLE_STATE.getXpath())).getText(); + return lifecycleStateDiv.findElement(By.xpath(XpathSelector.FORM_LIFE_CYCLE_STATE.getXpath())).getText(); } /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ @AllArgsConstructor - public enum XpathSelector { + private enum XpathSelector { MAIN_DIV("sdc-workspace-top-bar", "//div[@class='%s']"), LIFECYCLE_STATE_DIV("lifecycle-state", "//div[@class='%s']"), VERSION_CONTAINER_DIV("version-container", "//div[@class='%s']"), diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ServiceCreatePage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ServiceCreatePage.java index 3a1f3bc78b..e9fc3876d2 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ServiceCreatePage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ServiceCreatePage.java @@ -22,11 +22,9 @@ package org.onap.sdc.frontend.ci.tests.pages; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalToIgnoringCase; import static org.hamcrest.core.Is.is; -import static org.onap.sdc.frontend.ci.tests.pages.ServiceCreatePage.XpathSelector.CATEGORY_SELECT; -import static org.onap.sdc.frontend.ci.tests.pages.ServiceCreatePage.XpathSelector.DESCRIPTION_TEXT_AREA; -import static org.onap.sdc.frontend.ci.tests.pages.ServiceCreatePage.XpathSelector.ETSI_VERSION_SELECT; -import static org.onap.sdc.frontend.ci.tests.pages.ServiceCreatePage.XpathSelector.NAME_INPUT; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.onap.sdc.frontend.ci.tests.datatypes.LifeCycleStateEnum; import org.onap.sdc.frontend.ci.tests.datatypes.ServiceCreateData; import org.onap.sdc.frontend.ci.tests.utilities.LoaderHelper; @@ -62,6 +60,7 @@ public class ServiceCreatePage extends AbstractPageObject { /** * Fill the service create form based on the given ServiceCreateData + * * @param serviceCreateData the form data */ public void fillForm(final ServiceCreateData serviceCreateData) { @@ -75,7 +74,7 @@ public class ServiceCreatePage extends AbstractPageObject { if (etsiVersion == null) { return; } - final Select categorySelect = new Select(waitForElementVisibility(By.xpath(ETSI_VERSION_SELECT.getXpath()))); + final Select categorySelect = new Select(waitForElementVisibility(By.xpath(XpathSelector.ETSI_VERSION_SELECT.getXpath()))); categorySelect.selectByVisibleText(etsiVersion); } @@ -83,7 +82,7 @@ public class ServiceCreatePage extends AbstractPageObject { if (category == null) { return; } - final Select categorySelect = new Select(findElement(By.xpath(CATEGORY_SELECT.getXpath()))); + final Select categorySelect = new Select(findElement(By.xpath(XpathSelector.CATEGORY_SELECT.getXpath()))); categorySelect.selectByVisibleText(category); } @@ -91,7 +90,7 @@ public class ServiceCreatePage extends AbstractPageObject { if (description == null) { return; } - findElement(By.xpath(DESCRIPTION_TEXT_AREA.getXpath())) + findElement(By.xpath(XpathSelector.DESCRIPTION_TEXT_AREA.getXpath())) .sendKeys(description); } @@ -99,7 +98,7 @@ public class ServiceCreatePage extends AbstractPageObject { if (name == null) { return; } - findElement(By.xpath(NAME_INPUT.getXpath())) + findElement(By.xpath(XpathSelector.NAME_INPUT.getXpath())) .sendKeys(name); } @@ -112,26 +111,17 @@ public class ServiceCreatePage extends AbstractPageObject { /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ - public enum XpathSelector { - CREATE_BTN("create/save", "//button[@data-tests-id='%s']"), - FORM_LIFE_CYCLE_STATE("formlifecyclestate", "//span[@data-tests-id='%s']"), + @AllArgsConstructor + private enum XpathSelector { NAME_INPUT("name", "//input[@data-tests-id='%s']"), CATEGORY_SELECT("selectGeneralCategory", "//select[@data-tests-id='%s']"), ETSI_VERSION_SELECT("ETSI Version", "//select[@data-tests-id='%s']"), DESCRIPTION_TEXT_AREA("description", "//textarea[@data-tests-id='%s']"); + @Getter private final String id; private final String xpathFormat; - XpathSelector(final String id, final String xpathFormat) { - this.id = id; - this.xpathFormat = xpathFormat; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpathFormat, id); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/SoftwareProductOnboarding.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/SoftwareProductOnboarding.java index cb485b7c18..2dc008657e 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/SoftwareProductOnboarding.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/SoftwareProductOnboarding.java @@ -20,15 +20,9 @@ package org.onap.sdc.frontend.ci.tests.pages; import static org.hamcrest.MatcherAssert.assertThat; -import static org.onap.sdc.frontend.ci.tests.pages.SoftwareProductOnboarding.XpathSelector.ATTACHMENT_VIEW; -import static org.onap.sdc.frontend.ci.tests.pages.SoftwareProductOnboarding.XpathSelector.BNT_SUBMIT; -import static org.onap.sdc.frontend.ci.tests.pages.SoftwareProductOnboarding.XpathSelector.FILE_INPUT; -import static org.onap.sdc.frontend.ci.tests.pages.SoftwareProductOnboarding.XpathSelector.NAV_BAR_GROUP_ITEM_ATTACHMENT; -import static org.onap.sdc.frontend.ci.tests.pages.SoftwareProductOnboarding.XpathSelector.NAV_BAR_GROUP_NAME_XPATH; -import static org.onap.sdc.frontend.ci.tests.pages.SoftwareProductOnboarding.XpathSelector.ONBOARDING_LOADER_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.SoftwareProductOnboarding.XpathSelector.PAGE_MAIN_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.SoftwareProductOnboarding.XpathSelector.SELECTED_NAV_BAR_GROUP_ITEM; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.hamcrest.core.Is; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; @@ -57,35 +51,35 @@ public class SoftwareProductOnboarding extends AbstractPageObject { } public String getResourceName() { - return wrappingElement.findElement(By.xpath(NAV_BAR_GROUP_NAME_XPATH.getXpath())).getText(); + return wrappingElement.findElement(By.xpath(XpathSelector.NAV_BAR_GROUP_NAME_XPATH.getXpath())).getText(); } public void uploadFile(final String resourceFilePath) { LOGGER.debug("Uploading file '{}'", resourceFilePath); - setInputValue(FILE_INPUT, resourceFilePath); + setInputValue(XpathSelector.FILE_INPUT, resourceFilePath); } public void attachmentScreenIsLoaded() { - final String attachmentViewXpath = String.format("%s%s", PAGE_MAIN_DIV.getXpath(), ATTACHMENT_VIEW.getXpath()); + final String attachmentViewXpath = String.format("%s%s", XpathSelector.PAGE_MAIN_DIV.getXpath(), XpathSelector.ATTACHMENT_VIEW.getXpath()); waitForElementVisibility(By.xpath(attachmentViewXpath)); - waitForElementInvisibility(By.xpath(ONBOARDING_LOADER_DIV.getXpath())); + waitForElementInvisibility(By.xpath(XpathSelector.ONBOARDING_LOADER_DIV.getXpath())); final WebElement selectedNavBarGroupItem = - findSubElement(wrappingElement, SELECTED_NAV_BAR_GROUP_ITEM.getXpath()); + findSubElement(wrappingElement, XpathSelector.SELECTED_NAV_BAR_GROUP_ITEM.getXpath()); final String selectedNavBarGroupItemTestId = selectedNavBarGroupItem.getAttribute("data-test-id"); assertThat("Attachment menu should be selected", selectedNavBarGroupItemTestId, - Is.is(NAV_BAR_GROUP_ITEM_ATTACHMENT.getId())); + Is.is(XpathSelector.NAV_BAR_GROUP_ITEM_ATTACHMENT.getId())); } public void submit() { - findSubElement(wrappingElement, BNT_SUBMIT.getXpath()).click(); + findSubElement(wrappingElement, XpathSelector.BNT_SUBMIT.getXpath()).click(); vspCommitModal.isLoaded(); vspCommitModal.fillCommentWithDefaulMessage(); vspCommitModal.submit(); } public WebElement getWrappingElement() { - LOGGER.debug("Finding element with xpath '{}'", PAGE_MAIN_DIV.getXpath()); - return waitForElementVisibility(PAGE_MAIN_DIV.getXpath()); + LOGGER.debug("Finding element with xpath '{}'", XpathSelector.PAGE_MAIN_DIV.getXpath()); + return waitForElementVisibility(XpathSelector.PAGE_MAIN_DIV.getXpath()); } @@ -96,7 +90,8 @@ public class SoftwareProductOnboarding extends AbstractPageObject { /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ - public enum XpathSelector { + @AllArgsConstructor + private enum XpathSelector { PAGE_MAIN_DIV("software-product-view", DIV_CLASS_XPATH_FORMAT), UPLOAD_CSAR("upload-btn", "//input[@data-test-id='%s']"), FILE_INPUT("fileInput", "//input[@name='%s']"), @@ -107,18 +102,10 @@ public class SoftwareProductOnboarding extends AbstractPageObject { ONBOARDING_LOADER_DIV("onboarding-loader-backdrop", DIV_CLASS_XPATH_FORMAT), ATTACHMENT_VIEW("vsp-attachments-view", DIV_CLASS_XPATH_FORMAT); + @Getter private final String id; private final String xpathFormat; - XpathSelector(final String id, final String xpathFormat) { - this.id = id; - this.xpathFormat = xpathFormat; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpathFormat, id); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/TopNavComponent.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/TopNavComponent.java index 6b8e4cfbcc..56b584af8c 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/TopNavComponent.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/TopNavComponent.java @@ -19,6 +19,9 @@ package org.onap.sdc.frontend.ci.tests.pages; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory; import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.By; @@ -29,15 +32,6 @@ import org.openqa.selenium.support.ui.ExpectedConditions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; - -import static org.onap.sdc.frontend.ci.tests.pages.TopNavComponent.XpathSelector.*; -import static org.onap.sdc.frontend.ci.tests.pages.TopNavComponent.XpathSelector.ARROW_DROPDOWN; -import static org.onap.sdc.frontend.ci.tests.pages.TopNavComponent.XpathSelector.MAIN_MENU_ONBOARD_BTN; -import static org.onap.sdc.frontend.ci.tests.pages.TopNavComponent.XpathSelector.NAV; -import static org.onap.sdc.frontend.ci.tests.pages.TopNavComponent.XpathSelector.REPOSITORY_ICON; -import static org.onap.sdc.frontend.ci.tests.pages.TopNavComponent.XpathSelector.SUB_MENU_BUTTON_HOME; - /** * Handles the Top Navigation Component UI actions */ @@ -46,7 +40,7 @@ public class TopNavComponent extends AbstractPageObject { private static final Logger LOGGER = LoggerFactory.getLogger(TopNavComponent.class); private WebElement wrappingElement; - private By navLocator = By.xpath(NAV.getXpath()); + private By navLocator = By.xpath(XpathSelector.NAV.getXpath()); public TopNavComponent(final WebDriver webDriver) { super(webDriver); @@ -64,7 +58,7 @@ public class TopNavComponent extends AbstractPageObject { * @return the enclosing element */ public WebElement getWrappingElement() { - LOGGER.debug("Finding element with xpath '{}'", NAV.getXpath()); + LOGGER.debug("Finding element with xpath '{}'", XpathSelector.NAV.getXpath()); return waitForElementVisibility(navLocator); } @@ -73,15 +67,15 @@ public class TopNavComponent extends AbstractPageObject { */ public void clickOnHome() { hoverToBreadcrumbArrow(0); - final By homeButtonLocator = By.xpath(SUB_MENU_BUTTON_HOME.getXpath()); + final By homeButtonLocator = By.xpath(XpathSelector.SUB_MENU_BUTTON_HOME.getXpath()); getWait().until(ExpectedConditions.visibilityOfElementLocated(homeButtonLocator)); getWait().until(ExpectedConditions.elementToBeClickable(homeButtonLocator)).click(); getWait() - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(REPOSITORY_ICON.getXpath()))); + .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.REPOSITORY_ICON.getXpath()))); } public boolean isHomeSelected() { - final By homeLinkLocator = By.xpath(MAIN_MENU_LINK_HOME.getXpath()); + final By homeLinkLocator = By.xpath(XpathSelector.MAIN_MENU_LINK_HOME.getXpath()); getWait().until(ExpectedConditions.visibilityOfElementLocated(homeLinkLocator)); final WebElement homeLinkElement = findElement(homeLinkLocator); final WebElement homeLinkParentElement = homeLinkElement.findElement(By.xpath("./..")); @@ -95,7 +89,7 @@ public class TopNavComponent extends AbstractPageObject { * @return the next page object */ public VspRepositoryModalComponent clickOnRepositoryIcon() { - wrappingElement.findElement(By.xpath(REPOSITORY_ICON.getXpath())).click(); + wrappingElement.findElement(By.xpath(XpathSelector.REPOSITORY_ICON.getXpath())).click(); return new VspRepositoryModalComponent(webDriver); } @@ -106,7 +100,7 @@ public class TopNavComponent extends AbstractPageObject { * @return the next page object */ public OnboardHomePage clickOnOnboard() { - wrappingElement.findElement(By.xpath(MAIN_MENU_ONBOARD_BTN.getXpath())).click(); + wrappingElement.findElement(By.xpath(XpathSelector.MAIN_MENU_ONBOARD_BTN.getXpath())).click(); return new OnboardHomePage(DriverFactory.getDriver(), new OnboardHeaderComponent(DriverFactory.getDriver())); } @@ -120,7 +114,7 @@ public class TopNavComponent extends AbstractPageObject { final Actions actions = new Actions(GeneralUIUtils.getDriver()); final List<WebElement> arrowElementList = getWait() .until( - ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(ARROW_DROPDOWN.getXpath()))); + ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(XpathSelector.ARROW_DROPDOWN.getXpath()))); final WebElement selectedArrowElement = arrowElementList.get(arrowPosition); actions.moveToElement(selectedArrowElement).perform(); return selectedArrowElement; @@ -129,7 +123,8 @@ public class TopNavComponent extends AbstractPageObject { /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ - public enum XpathSelector { + @AllArgsConstructor + private enum XpathSelector { NAV("top-nav", "//nav[@class='%s']"), SUB_MENU_BUTTON_HOME("sub-menu-button-home", "//*[@data-tests-id='%s']"), MAIN_MENU_LINK_HOME("main-menu-button-home", "//*[@data-tests-id='%s']"), @@ -137,18 +132,10 @@ public class TopNavComponent extends AbstractPageObject { MAIN_MENU_ONBOARD_BTN("main-menu-button-onboard", "//a[@data-tests-id='%s']"), REPOSITORY_ICON("repository-icon", "//*[@data-tests-id='%s']"); + @Getter private final String id; private final String xpathFormat; - XpathSelector(final String id, final String xpathFormat) { - this.id = id; - this.xpathFormat = xpathFormat; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpathFormat, id); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCommitModal.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCommitModal.java index eb070e98a2..5c1928cf36 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCommitModal.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCommitModal.java @@ -19,6 +19,8 @@ package org.onap.sdc.frontend.ci.tests.pages; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; @@ -27,12 +29,6 @@ import org.openqa.selenium.support.ui.ExpectedConditions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.onap.sdc.frontend.ci.tests.pages.VspCommitModal.XpathSelector.COMMIT_AND_SUBMIT_BTN; -import static org.onap.sdc.frontend.ci.tests.pages.VspCommitModal.XpathSelector.COMMIT_COMMENT_TXT; -import static org.onap.sdc.frontend.ci.tests.pages.VspCommitModal.XpathSelector.MODAL_CANCEL_BTN; -import static org.onap.sdc.frontend.ci.tests.pages.VspCommitModal.XpathSelector.MODAL_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.VspCommitModal.XpathSelector.SUCCESS_MODAL_DIV; - /** * Handles the VSP Commit Modal UI actions */ @@ -47,15 +43,15 @@ public class VspCommitModal extends AbstractPageObject { } public void isLoaded() { - LOGGER.debug("Finding element with xpath '{}'", MODAL_DIV.getXpath()); - wrappingElement = waitForElementVisibility(MODAL_DIV.getXpath()); + LOGGER.debug("Finding element with xpath '{}'", XpathSelector.MODAL_DIV.getXpath()); + wrappingElement = waitForElementVisibility(XpathSelector.MODAL_DIV.getXpath()); } /** * Fills the comment text area with a default message. */ public void fillCommentWithDefaulMessage() { - final WebElement commentTxt = wrappingElement.findElement(By.xpath(COMMIT_COMMENT_TXT.getXpath())); + final WebElement commentTxt = wrappingElement.findElement(By.xpath(XpathSelector.COMMIT_COMMENT_TXT.getXpath())); commentTxt.sendKeys("First VSP version"); } @@ -63,7 +59,7 @@ public class VspCommitModal extends AbstractPageObject { * Clicks on the modal submit and confirms success. */ public void submit() { - final WebElement commitAndSubmitBtn = wrappingElement.findElement(By.xpath(COMMIT_AND_SUBMIT_BTN.getXpath())); + final WebElement commitAndSubmitBtn = wrappingElement.findElement(By.xpath(XpathSelector.COMMIT_AND_SUBMIT_BTN.getXpath())); commitAndSubmitBtn.click(); GeneralUIUtils.ultimateWait(); confirmSuccess(); @@ -74,32 +70,25 @@ public class VspCommitModal extends AbstractPageObject { */ private void confirmSuccess() { final WebElement successModal = getWait() - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(SUCCESS_MODAL_DIV.getXpath()))); - successModal.findElement(By.xpath(MODAL_CANCEL_BTN.getXpath())).click(); + .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.SUCCESS_MODAL_DIV.getXpath()))); + successModal.findElement(By.xpath(XpathSelector.MODAL_CANCEL_BTN.getXpath())).click(); } /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ - public enum XpathSelector { + @AllArgsConstructor + private enum XpathSelector { MODAL_DIV("sdc-modal-type-custom", "//div[contains(@class, '%s')]"), COMMIT_AND_SUBMIT_BTN("form-submit-button", "//button[@data-test-id='%s']"), COMMIT_COMMENT_TXT("commit-comment-text", "//textarea[@data-test-id='%s']"), SUCCESS_MODAL_DIV("sdc-modal-type-info", "//div[contains(@class, '%s')]"), MODAL_CANCEL_BTN("sdc-modal-cancel-button", "//button[@data-test-id='%s']"); + @Getter private final String id; private final String xpath; - XpathSelector(final String id, final String xpath) { - this.id = id; - this.xpath = xpath; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpath, id); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCreationModal.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCreationModal.java index 02cec1df41..e83eac4ea0 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCreationModal.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCreationModal.java @@ -19,6 +19,8 @@ package org.onap.sdc.frontend.ci.tests.pages; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -26,9 +28,6 @@ import org.openqa.selenium.support.ui.Select; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.onap.sdc.frontend.ci.tests.pages.VspCreationModal.XpathSelector.METHOD_RADIO; -import static org.onap.sdc.frontend.ci.tests.pages.VspCreationModal.XpathSelector.MODAL_XPATH; - /** * Handles the VSP Creation Modal UI actions */ @@ -45,8 +44,8 @@ public class VspCreationModal extends AbstractPageObject { @Override public void isLoaded() { - LOGGER.debug("Finding element with xpath '{}'", MODAL_XPATH.getXpath()); - wrappingElement = waitForElementVisibility(MODAL_XPATH.getXpath()); + LOGGER.debug("Finding element with xpath '{}'", XpathSelector.MODAL_XPATH.getXpath()); + wrappingElement = waitForElementVisibility(XpathSelector.MODAL_XPATH.getXpath()); } /** @@ -110,7 +109,7 @@ public class VspCreationModal extends AbstractPageObject { * Selects the network package onboarding procedure option. */ public void selectNetworkPackageOnboardingProcedure() { - wrappingElement.findElement(By.xpath(METHOD_RADIO.getXpath())).click(); + wrappingElement.findElement(By.xpath(XpathSelector.METHOD_RADIO.getXpath())).click(); } private void setInputValue(final XpathSelector inputTestId, final String value) { @@ -132,7 +131,8 @@ public class VspCreationModal extends AbstractPageObject { /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ - public enum XpathSelector { + @AllArgsConstructor + private enum XpathSelector { MODAL_XPATH("software-product-creation-page", "//div[@class='%s']"), NAME_TXT("new-vsp-name", "//input[@data-test-id='%s']"), VENDOR_SELECT("new-vsp-vendor", "//select[@data-test-id='%s']"), @@ -141,18 +141,10 @@ public class VspCreationModal extends AbstractPageObject { METHOD_RADIO("new-vsp-creation-procedure-heat", "//input[@data-test-id='%s']/parent::label"), CREATE_BTN("form-submit-button", "//*[@data-test-id='%s']"); + @Getter private final String id; private final String xpathFormat; - XpathSelector(final String id, final String xpathFormat) { - this.id = id; - this.xpathFormat = xpathFormat; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpathFormat, id); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspRepositoryModalComponent.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspRepositoryModalComponent.java index 4e3b939ae7..0cf7dbd501 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspRepositoryModalComponent.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspRepositoryModalComponent.java @@ -23,12 +23,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; -import static org.onap.sdc.frontend.ci.tests.pages.VspRepositoryModalComponent.XpathSelector.IMPORT_VSP_BTN; -import static org.onap.sdc.frontend.ci.tests.pages.VspRepositoryModalComponent.XpathSelector.MODAL_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.VspRepositoryModalComponent.XpathSelector.RESULTS_CONTAINER_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.VspRepositoryModalComponent.XpathSelector.SEARCH_TXT; import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils; import org.onap.sdc.frontend.ci.tests.utilities.LoaderHelper; import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent; @@ -57,7 +55,7 @@ public class VspRepositoryModalComponent extends AbstractPageObject { wrappingElement = getWrappingElement(); GeneralUIUtils.ultimateWait(); final List<WebElement> vspResultList = wrappingElement - .findElements(By.className(RESULTS_CONTAINER_DIV.getId())); + .findElements(By.className(XpathSelector.RESULTS_CONTAINER_DIV.getId())); assertThat("VSP Repository should contain at least one result", vspResultList, is(not(empty()))); } @@ -69,9 +67,9 @@ public class VspRepositoryModalComponent extends AbstractPageObject { */ public ResourceCreatePage clickOnImportVsp(final int listPosition) { final List<WebElement> vspResultList = - findSubElements(wrappingElement, By.className(RESULTS_CONTAINER_DIV.getId())); + findSubElements(wrappingElement, By.className(XpathSelector.RESULTS_CONTAINER_DIV.getId())); vspResultList.get(listPosition).click(); - GeneralUIUtils.clickOnElementByTestId(IMPORT_VSP_BTN.getId()); + GeneralUIUtils.clickOnElementByTestId(XpathSelector.IMPORT_VSP_BTN.getId()); return new ResourceCreatePage(webDriver, new LoaderHelper(), new NotificationComponent(webDriver)); } @@ -81,7 +79,7 @@ public class VspRepositoryModalComponent extends AbstractPageObject { * @param vspName the VSP name to search */ public void searchForVSP(final String vspName) { - final WebElement searchTxtElement = findSubElement(wrappingElement, By.xpath(SEARCH_TXT.getXpath())); + final WebElement searchTxtElement = findSubElement(wrappingElement, By.xpath(XpathSelector.SEARCH_TXT.getXpath())); searchTxtElement.sendKeys(vspName); GeneralUIUtils.ultimateWait(); } @@ -92,31 +90,24 @@ public class VspRepositoryModalComponent extends AbstractPageObject { * @return the enclosing element */ public WebElement getWrappingElement() { - LOGGER.debug("Finding element with xpath '{}'", MODAL_DIV.getXpath()); - return waitForElementVisibility(MODAL_DIV.getXpath()); + LOGGER.debug("Finding element with xpath '{}'", XpathSelector.MODAL_DIV.getXpath()); + return waitForElementVisibility(XpathSelector.MODAL_DIV.getXpath()); } /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ - public enum XpathSelector { + @AllArgsConstructor + private enum XpathSelector { MODAL_DIV("importVspTable", "//*[@data-tests-id='%s']"), SEARCH_TXT("onboarding-search-input", "//input[@data-tests-id='%s']"), IMPORT_VSP_BTN("import-csar", "//*[@data-tests-id='%s']"), RESULTS_CONTAINER_DIV("datatable-body-cell-label", "//datatable-body[contains(@class,'%s']"); + @Getter private final String id; private final String xpathFormat; - XpathSelector(final String id, final String xpathFormat) { - this.id = id; - this.xpathFormat = xpathFormat; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpathFormat, id); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/ToscaArtifactsPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/ToscaArtifactsPage.java index 17ddae194f..a691fba06e 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/ToscaArtifactsPage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/ToscaArtifactsPage.java @@ -19,10 +19,6 @@ package org.onap.sdc.frontend.ci.tests.pages.component.workspace; -import static org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage.XpathSelector.DATA_TABLE_BODY; -import static org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage.XpathSelector.DOWNLOAD_LINK; -import static org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage.XpathSelector.MAIN_DIV; -import static org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage.XpathSelector.TITLE_DIV; import java.util.ArrayList; import java.util.List; @@ -35,9 +31,9 @@ import org.openqa.selenium.WebElement; public class ToscaArtifactsPage extends AbstractPageObject { + private final List<String> downloadedArtifactList = new ArrayList<>(); private WebElement wrappingElement; private WebElement artifactsTableBody; - private final List<String> downloadedArtifactList = new ArrayList<>(); public ToscaArtifactsPage(final WebDriver webDriver) { super(webDriver); @@ -45,13 +41,13 @@ public class ToscaArtifactsPage extends AbstractPageObject { @Override public void isLoaded() { - wrappingElement = waitForElementVisibility(By.xpath(MAIN_DIV.getXpath()), 5); - waitForElementVisibility(By.xpath(TITLE_DIV.getXpath()), 5); - artifactsTableBody = waitForElementVisibility(By.xpath(DATA_TABLE_BODY.getXpath()), 5); + wrappingElement = waitForElementVisibility(By.xpath(XpathSelector.MAIN_DIV.getXpath()), 5); + waitForElementVisibility(By.xpath(XpathSelector.TITLE_DIV.getXpath()), 5); + artifactsTableBody = waitForElementVisibility(By.xpath(XpathSelector.DATA_TABLE_BODY.getXpath()), 5); } public void clickOnDownload(final String artifactName) { - artifactsTableBody.findElement(By.xpath(DOWNLOAD_LINK.getXpath(artifactName))).click(); + artifactsTableBody.findElement(By.xpath(XpathSelector.DOWNLOAD_LINK.getXpath(artifactName))).click(); } public void addToDownloadedArtifactList(final String downloadedArtifactName) { @@ -69,7 +65,7 @@ public class ToscaArtifactsPage extends AbstractPageObject { * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ @AllArgsConstructor - public enum XpathSelector { + private enum XpathSelector { MAIN_DIV("w-sdc-main-right-container", "//div[@class='%s']"), TITLE_DIV("tab-title", "//div[contains(@class,'%s') and contains(text(), 'TOSCA Artifacts')]"), DATA_TABLE_BODY("//datatable-body"), @@ -77,7 +73,6 @@ public class ToscaArtifactsPage extends AbstractPageObject { @Getter private String id; - private final String xpathFormat; XpathSelector(final String xpathFormat) { diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java index b4f17dd255..f39f21d482 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java @@ -21,9 +21,8 @@ package org.onap.sdc.frontend.ci.tests.pages.home; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; -import static org.onap.sdc.frontend.ci.tests.pages.home.HomePage.XpathSelector.ADD_BUTTONS_AREA; -import static org.onap.sdc.frontend.ci.tests.pages.home.HomePage.XpathSelector.ADD_SERVICE_BTN; +import lombok.AllArgsConstructor; import lombok.Getter; import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject; import org.onap.sdc.frontend.ci.tests.pages.ServiceCreatePage; @@ -59,7 +58,7 @@ public class HomePage extends AbstractPageObject { */ public ServiceCreatePage clickOnAddService() { hoverToAddArea(); - final By addServiceBtnLocator = By.xpath(ADD_SERVICE_BTN.getXpath()); + final By addServiceBtnLocator = By.xpath(XpathSelector.ADD_SERVICE_BTN.getXpath()); waitForElementVisibility(addServiceBtnLocator); final WebElement addServiceBtn = findElement(addServiceBtnLocator); addServiceBtn.click(); @@ -73,7 +72,7 @@ public class HomePage extends AbstractPageObject { */ public WebElement hoverToAddArea() { final Actions actions = new Actions(webDriver); - final By addButtonsAreaLocator = By.xpath(ADD_BUTTONS_AREA.getXpath()); + final By addButtonsAreaLocator = By.xpath(XpathSelector.ADD_BUTTONS_AREA.getXpath()); final WebElement addButtonsAreaElement = findElement(addButtonsAreaLocator); actions.moveToElement(addButtonsAreaElement).build().perform(); return addButtonsAreaElement; @@ -82,22 +81,15 @@ public class HomePage extends AbstractPageObject { /** * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object. */ - public enum XpathSelector { + @AllArgsConstructor + private enum XpathSelector { ADD_SERVICE_BTN("createServiceButton", "//*[@data-tests-id='%s']"), ADD_BUTTONS_AREA("AddButtonsArea", "//*[@data-tests-id='%s']"); + @Getter private final String id; private final String xpathFormat; - XpathSelector(final String id, final String xpathFormat) { - this.id = id; - this.xpathFormat = xpathFormat; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpathFormat, id); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/NotificationComponent.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/NotificationComponent.java index 676b0a1224..26db4828f7 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/NotificationComponent.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/NotificationComponent.java @@ -19,10 +19,8 @@ package org.onap.sdc.frontend.ci.tests.utilities; -import static org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent.XpathSelector.MAIN_CONTAINER_DIV; -import static org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent.XpathSelector.MESSAGE_CONTENT_DIV; -import static org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent.XpathSelector.MESSAGE_SUCCESS_DIV; - +import lombok.AllArgsConstructor; +import lombok.Getter; import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; @@ -32,12 +30,12 @@ import org.slf4j.LoggerFactory; public class NotificationComponent extends AbstractPageObject { + private static final Logger LOGGER = LoggerFactory.getLogger(NotificationComponent.class); + public NotificationComponent(final WebDriver webDriver) { super(webDriver); } - private static final Logger LOGGER = LoggerFactory.getLogger(NotificationComponent.class); - public void waitForNotification(final NotificationType notificationType, final int timeout) { final By messageLocator = getMessageLocator(notificationType); final WebElement webElement = waitForElementVisibility(messageLocator, timeout); @@ -51,7 +49,8 @@ public class NotificationComponent extends AbstractPageObject { private String getMessageXpath(final NotificationType notificationType) { if (notificationType == NotificationType.SUCCESS) { - return String.format("%s%s%s", MAIN_CONTAINER_DIV.getXpath(), MESSAGE_CONTENT_DIV.getXpath(), MESSAGE_SUCCESS_DIV.getXpath()); + return String.format("%s%s%s", XpathSelector.MAIN_CONTAINER_DIV.getXpath(), XpathSelector.MESSAGE_CONTENT_DIV.getXpath(), + XpathSelector.MESSAGE_SUCCESS_DIV.getXpath()); } LOGGER.warn("Xpath for NotificationType {} not yet implemented.", notificationType); @@ -63,23 +62,17 @@ public class NotificationComponent extends AbstractPageObject { //will not be loaded when needed } - public enum XpathSelector { + @AllArgsConstructor + private enum XpathSelector { MAIN_CONTAINER_DIV("notification-container", "//div[@class='%s']"), MESSAGE_CONTENT_DIV("msg-content", "//div[@class='%s']"), - MESSAGE_SUCCESS_DIV("message", "//div[contains(@class, 'message') and (contains(text(),'successfully') or contains(text(), 'Successfully'))]"); + MESSAGE_SUCCESS_DIV("message", + "//div[contains(@class, 'message') and (contains(text(),'successfully') or contains(text(), 'Successfully'))]"); + @Getter private final String id; private final String xpath; - XpathSelector(String id, String xpath) { - this.id = id; - this.xpath = xpath; - } - - public String getId() { - return id; - } - public String getXpath() { return String.format(xpath, id); } |