diff options
Diffstat (limited to 'ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages')
23 files changed, 2647 insertions, 0 deletions
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/AdminGeneralPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/AdminGeneralPage.java new file mode 100644 index 0000000000..98ef4318c8 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/AdminGeneralPage.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.List; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.UserManagementTab; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.WebElement; + +import com.aventstack.extentreports.Status; + +public class AdminGeneralPage extends GeneralPageElements { + + public AdminGeneralPage() { + super(); + } + + private static UserManagementTab userManagementTab = new UserManagementTab(); + + public static UserManagementTab getUserManagementTab() { + return userManagementTab; + } + + public static void selectCategoryManagmetTab() throws Exception { + + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.AdminPageTabs.CATEGORY_MANAGEMENT.getValue()); + } + + public static void selectUserManagmetTab() throws Exception { + + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.AdminPageTabs.USER_MANAGEMENT.getValue()); + } + + public static List<WebElement> getServiceCategoriesList() throws Exception { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.SERVICE_CATEGORY_HEADER.getValue()); + GeneralUIUtils.waitForLoader(); + return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.CategoryManagement.SERVICE_CATEGORY_LIST.getValue()); + } + + public static List<WebElement> getResourceCategoriesList() throws Exception { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_HEADER.getValue()); + GeneralUIUtils.waitForLoader(); + return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_LIST.getValue()); + } + + public static void createNewServiceCategory(String name) throws Exception { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.SERVICE_CATEGORY_HEADER.getValue()); + SetupCDTest.getExtendTest().log(Status.INFO, "Creating service..."); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.NEW_CATEGORY_BUTTON.getValue()); + GeneralUIUtils.waitForLoader(); + defineNewResourceCategoryName(name); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); + GeneralUIUtils.waitForLoader(); + } + + public static void selectElementFromList(List<WebElement> list, String elementToSelect) throws Exception { + + for (WebElement webElement : list) { + if (webElement.getText().toLowerCase().equals(elementToSelect.toLowerCase())){ + webElement.click(); + } + } + + } + + + + public static void addSubCategoryToResource(List<WebElement> resourceList, String parentResource, String subCategoryName) throws Exception{ + + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_HEADER.getValue()); + selectElementFromList(resourceList, parentResource); + SetupCDTest.getExtendTest().log(Status.INFO, "Creating..."); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.NEW_SUB_CATEGORY_BUTTON.getValue()); + GeneralUIUtils.waitForLoader(); + defineNewResourceCategoryName(subCategoryName); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); + GeneralUIUtils.waitForLoader(); + + + } + + public static void createNewResourceCategory(String name) throws Exception { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_HEADER.getValue()); + SetupCDTest.getExtendTest().log(Status.INFO, "Creating..."); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.NEW_CATEGORY_BUTTON.getValue()); + GeneralUIUtils.waitForLoader(); + defineNewResourceCategoryName(name); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); + GeneralUIUtils.waitForLoader(); + + } + + public void insertPropertyDefaultValue(String value) { + WebElement propertyValue = GeneralUIUtils + .getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_VALUE.getValue()); + propertyValue.clear(); + propertyValue.sendKeys(value); + } + + private static void defineNewResourceCategoryName(String name) { + WebElement categoryNameTextbox = getCategoryName(); + categoryNameTextbox.clear(); + categoryNameTextbox.sendKeys(name); + } + + private static WebElement getCategoryName() { + return GeneralUIUtils.getWebElementByClassName(DataTestIdEnum.CategoryManagement.NEW_CATEGORY_NAME.getValue()); + } + + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ComponentLeftMenu.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ComponentLeftMenu.java new file mode 100644 index 0000000000..d795599f24 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ComponentLeftMenu.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +public interface ComponentLeftMenu { + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/CompositionPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/CompositionPage.java new file mode 100644 index 0000000000..496c537d49 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/CompositionPage.java @@ -0,0 +1,197 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.List; + +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.Select; + +import com.aventstack.extentreports.Status; + +public class CompositionPage extends GeneralPageElements { + + public CompositionPage() { + super(); + } + + public static UploadArtifactPopup artifactPopup() { + return new UploadArtifactPopup(true); + } + + public static void searchForElement(String elementName) { + SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + elementName + " in the left panel"); + WebElement searchField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.SEARCH_ASSET.getValue()); + searchField.clear(); + searchField.sendKeys(elementName); + GeneralUIUtils.ultimateWait(); + } + + public static void showDeploymentArtifactTab() throws Exception { + clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB); + } + + public static void showInformationsTab() throws Exception { + clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.INFORMATION_TAB); + } + + public static void showPropertiesAndAttributesTab() throws Exception { + clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.PROPERTIES_AND_ATTRIBUTES_TAB); + } + + public static List<WebElement> getProperties() { + return PropertiesPage.getElemenetsFromTable(); + } + + public static List<WebElement> getDeploymentArtifacts() { + return getAllAddedArtifacts(); + } + + public static List<WebElement> getAllAddedArtifacts() { + String dataTestsId = DataTestIdEnum.CompositionScreenEnum.ARTIFACTS_LIST.getValue(); + return GeneralUIUtils.getWebElementsListBy(By.xpath("//*[contains(@data-tests-id,'" + dataTestsId + "')]")); + } + + public static void moveToInputsScreen() throws Exception { + OpenPagesMenu(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.MENU_INPUTS.getValue()); + GeneralUIUtils.ultimateWait(); + } + + private static void OpenPagesMenu() { + Actions actions = new Actions(GeneralUIUtils.getDriver()); + List<WebElement> triangleList = GeneralUIUtils.getWebElementsListByClassName(DataTestIdEnum.CompositionScreenEnum.MENU_TRIANGLE_DROPDOWN.getValue()); + WebElement pagesMenu = triangleList.get(2); + actions.moveToElement(pagesMenu).perform(); + } + + public static void changeComponentVersion(CanvasManager canvasManager, CanvasElement element, String version) { + try{ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Changing component version to %s", version)); + canvasManager.clickOnCanvaElement(element); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue()); + GeneralUIUtils.ultimateWait(); + Select selectlist = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue())); + while (selectlist.getOptions().size() == 0) { + selectlist = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue())); + } + GeneralUIUtils.ultimateWait();; + selectlist.selectByValue(version); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.clickSomewhereOnPage(); + } + catch(Exception e){ + throw e; + } + } + + public static void clickAddArtifactButton() throws Exception{ + clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.ADD_ARTIFACT); + GeneralUIUtils.getWebElementByClassName("sdc-add-artifact"); + } + + public static String getSelectedInstanceName(){ + return GeneralUIUtils.getWebElementByTestID("selectedCompTitle").getText(); + } + + public static void showInformationArtifactTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.INFORMATION_ARTIFACTS); + } + + public static void showAPIArtifactTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.API); + } + + public static void showInformationTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.INFORMATION); + } + + public static void showCompositionTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.COMPOSITION); + } + + public static void showInputsTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.INPUTS); + } + + public static void showRequirementsAndCapabilitiesTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.REQUIREMENTS_AND_CAPABILITIES); + } + + public static List<WebElement> getOpenTabTitle() throws Exception{ +// return GeneralUIUtils.getElementsByCSS("expand-collapse span"); + return GeneralUIUtils.getElementsByCSS("expand-collapse"); + } + + public static void clickOnTab(DataTestIdEnum.CompositionScreenEnum tabSelector) throws Exception{ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", tabSelector.name())); + GeneralUIUtils.getElementsByCSS(tabSelector.getValue()).get(0).click(); + GeneralUIUtils.ultimateWait(); + } + + public static void clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum tabSelector) throws Exception{ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", tabSelector.name())); + GeneralUIUtils.getWebElementByTestID(tabSelector.getValue()).click(); + GeneralUIUtils.ultimateWait(); + } + + public static CanvasElement addElementToCanvasScreen(LeftPanelCanvasItems elementName, CanvasManager vfCanvasManager) throws Exception{ + CompositionPage.searchForElement(elementName.name()); + return vfCanvasManager.createElementOnCanvas(elementName); + } + + public static CanvasElement addElementToCanvasScreen(String elementName, CanvasManager vfCanvasManager) throws Exception{ + CompositionPage.searchForElement(elementName); + return vfCanvasManager.createElementOnCanvas(elementName); + } + + public static List<WebElement> getCompositionDeplymentArtifacts() { + return GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue()); + } + public static WebElement getCustomizationUUID() throws Exception { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CUSTOMIZATION_UUID.getValue()); + } + + + public static List<WebElement> getCompositionEnvArtifacts(){ + return GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ENV.getValue()); + } + + public static WebElement clickDownloadEnvArtifactComposition(String fileName) { + GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ENV.getValue() + fileName); + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue() +fileName); + } + + + + + + + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentArtifactPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentArtifactPage.java new file mode 100644 index 0000000000..810a1f991c --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentArtifactPage.java @@ -0,0 +1,277 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.commons.lang.WordUtils; +import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; +import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.testng.collections.Lists; + +import com.aventstack.extentreports.Status; + +public class DeploymentArtifactPage extends GeneralPageElements { + + public DeploymentArtifactPage() { + super(); + } + + public static ResourceLeftMenu getLeftPanel() { + return new ResourceLeftMenu(); + } + + public static UploadArtifactPopup artifactPopup() { + return new UploadArtifactPopup(); + } + + protected static void addNewArtifact(ArtifactGroupTypeEnum artifactGroupType) { + switch (artifactGroupType) { + case DEPLOYMENT: + GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPageEnum.ADD_DEPLOYMENT_ARTIFACT.getValue()).click(); + break; + case INFORMATIONAL: + GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPageEnum.ADD_INFORMATIONAL_ARTIFACT.getValue()).click(); + break; + default: + break; + } + } + + public static void clickAddNewArtifact() { + addNewArtifact(ArtifactGroupTypeEnum.DEPLOYMENT); + } + + public static void clickAddAnotherArtifact() { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.ADD_ANOTHER_ARTIFACT.getValue()).click(); + } + + public static void clickEditArtifact(String artifactLabel) { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.EDIT_ARTIFACT.getValue() + artifactLabel).click(); + } + + public static void clickEditEnvArtifact(String artifactLabel) { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.EDIT_PARAMETERS_OF_ARTIFACT.getValue() + artifactLabel).click(); + } + + public static void clickDeleteArtifact(String artifactLabel) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Deleting %s Artefact ",artifactLabel)); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DELETE_ARTIFACT.getValue() + artifactLabel).click(); + } + + public static WebElement clickDownloadArtifact(String artifactLabel) { + WebElement downloadButton = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT.getValue() + artifactLabel); + + return downloadButton; + } + + public static void clickDownloadEnvArtifact(String envFileNameToDownload) { + ExtentTestActions.log(Status.INFO, String.format("Downloading the updated %s artifact for validate parameters with the response after the update...", envFileNameToDownload)); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue() + envFileNameToDownload); + ExtentTestActions.log(Status.INFO, String.format("%s Envartifact was downloaded successfully!", envFileNameToDownload)); + } + + public static void clickSaveEnvParameters() { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.SAVE.getValue()).click(); + GeneralUIUtils.ultimateWait(); + } + + public static WebElement getAddOtherArtifactButton(){ + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.ADD_ANOTHER_ARTIFACT.getValue()); + } + + public static void clickOK(){ + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.OK.getValue()).click(); + GeneralUIUtils.getWebElementBy(By.className("flex-container")); + GeneralUIUtils.waitForAngular(); + } + + public static String getArtifactDescription(String artifactLabel) throws Exception { + clickOnArtifactDescription(artifactLabel); // open artifact + WebElement artifactDescriptionElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.GET_DEPLOYMENT_ARTIFACT_DESCRIPTION.getValue()); + String artifactDesc = artifactDescriptionElement.getAttribute("value"); + closeArtifactDescription(artifactLabel); // close artifact + return artifactDesc; + } + + public static void closeArtifactDescription(String artifactLabel) { + GeneralUIUtils.clickOnElementByTestId("popover-x-button"); + } + + public static WebElement clickOnArtifactDescription(String artifactLabel) throws Exception { + try{ + WebElement artifact = GeneralUIUtils.getWebElementByTestID("descriptionIcon_" + artifactLabel); + artifact.click(); + GeneralUIUtils.waitForLoader(); + return artifact; + } + catch(Exception e){ + throw new Exception("Artifact " + artifactLabel + "is not found"); + } + } + + public static boolean checkElementsCountInTable(int expectedElementsCount) { + return GeneralPageElements.checkElementsCountInTable(expectedElementsCount + 1); + } + + public static String[] verifyArtifactsExistInTable(String filepath, String vnfFile) throws Exception{ + String[] artifactNamesFromZipFile = FileHandling.getArtifactsFromZip(filepath, vnfFile); + return verifyArtifactsExistInTable(artifactNamesFromZipFile); + } + + public static String[] verifyArtifactsExistInTable(String[] artifactNamesFromZipFile) throws Exception{ + if (artifactNamesFromZipFile != null){ + checkArtifactsDisplayed(artifactNamesFromZipFile); + checkEnvArtifactsDisplayed(); + } + + return artifactNamesFromZipFile; + } + + public static void checkArtifactsDisplayed(String[] artifactsFromZipFile) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the artifacts in the table"); + List<String> artifactList = Lists.newArrayList(artifactsFromZipFile).stream().filter(p -> !p.contains(".env")).map(p -> getVisualArtifactName(p)).collect(Collectors.toList()); + try{ +// List<WebElement> rows = GeneralUIUtils.getElementsByCSS("div div[data-tests-id^='artifact-item'] span.ng-binding:nth-of-type(2)"); + List<WebElement> rows = GeneralUIUtils.getElementsByCSS("div div[data-tests-id^='artifact-item'] span[data-tests-id^='artifactDisplayName']"); + for (WebElement r : rows){ + String artifactDisplayed = r.getAttribute("textContent").trim(); + if (artifactList.contains(artifactDisplayed)){ + artifactList.remove(artifactDisplayed); + } + else if (artifactDisplayed.toLowerCase().contains("license")){ + artifactList.add(artifactDisplayed); + } + } + checkLicenseArtifactsDisplayed(artifactList); + } + catch(Exception e){ + throw new Exception("Table problem"); + } + + + if (!artifactList.isEmpty()){ + throw new Exception(String.format("missing the following artifact(s) : %s", artifactList.toString())); + } + } + + public static void checkEnvArtifactsDisplayed() throws Exception { + List<WebElement> envRows; + List<WebElement> heatRows; + List<WebElement> heatNetRows; + List<WebElement> heatVolRows; + int envArtifactsSize = 0; + + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the HEAT_ENV artifacts in the table"); + + try{ + envRows = GeneralUIUtils.getElementsByCSS("div div[data-tests-id='HEAT_ENV']"); + + heatRows = GeneralUIUtils.getElementsByCSS("div div[tooltip-content='HEAT']"); + heatNetRows = GeneralUIUtils.getElementsByCSS("div div[tooltip-content='HEAT_NET']"); + heatVolRows = GeneralUIUtils.getElementsByCSS("div div[tooltip-content='HEAT_VOL']"); + + envArtifactsSize = heatRows.size() + heatNetRows.size() + heatVolRows.size(); + } + catch(Exception e){ + throw new Exception("Table problem"); + } + + if (envArtifactsSize !=envRows.size()){ + throw new Exception(String.format("some env artifacts are missing... there is %s instead of %s", envRows.size(), envArtifactsSize)); + } + + } + + public static void checkLicenseArtifactsDisplayed(List<String> rowsFromTable) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the license artifacts in the table"); + String vfLicense = getPreparedLicense(ArtifactTypeEnum.VF_LICENSE.getType()); + String[] split = vfLicense.split(" "); + vfLicense = vfLicense.replaceAll(split[0], split[0].toUpperCase()); + if (rowsFromTable.contains(vfLicense)){ + rowsFromTable.remove(vfLicense); + } + + String vendorLicense = getPreparedLicense(ArtifactTypeEnum.VENDOR_LICENSE.getType()); + if (rowsFromTable.contains(vendorLicense)){ + rowsFromTable.remove(vendorLicense); + } + + } + + public static String getPreparedLicense(String license) { + return WordUtils.capitalizeFully(license.replaceAll("_", " ")); + } + + + private static String getVisualArtifactName(String artifactName) { + if (artifactName.contains(".")){ + return artifactName.substring(0, artifactName.lastIndexOf(".")); + } + return artifactName; + } + + public static void updateDescription(String newDescription, ArtifactInfo artefact) throws Exception{ + UploadArtifactPopup artifactPopup = new UploadArtifactPopup(true); + DeploymentArtifactPage.clickEditArtifact(artefact.getArtifactLabel()); + artifactPopup.insertDescription(newDescription); + artifactPopup.clickDoneButton(); + } + + public static List<String> getDeploymentArtifactsNamesWorkSpace() { + return GeneralUIUtils.getWebElementListText(GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.ArtifactPageEnum.ARTIFACT_NAME.getValue())); + } + + //Get Artifact Type by Artifact Name. + public static String getArtifactType(String artifactName){ + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.TYPE.getValue()+artifactName).getText(); + } + + public static List<String> getHeatParametersInUI(String dataTestId){ + List<WebElement>elements; + List<String>Names=new ArrayList<>(); + elements=GeneralUIUtils.getWebElementsListByContainTestID(dataTestId); + for (WebElement webElement : elements) { + String attributevalue=webElement.getAttribute("data-tests-id"); + Names.add(attributevalue.replace("heatParameterName_", "")); + } + return Names; + } + + public static void searchBoxEnv(String parameterName) { + GeneralUIUtils.getWebElementByContainsClassName("w-sdc-env-search-input").sendKeys(parameterName); + } + + public static void clearSearchBoxEnv() { + GeneralUIUtils.getWebElementByContainsClassName("w-sdc-env-search-input").clear(); + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentPage.java new file mode 100644 index 0000000000..5ee85e099e --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentPage.java @@ -0,0 +1,239 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collector; +import java.util.stream.Collectors; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.DeploymentScreen; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import static org.testng.Assert.assertTrue; + + +import com.aventstack.extentreports.Status; + +public class DeploymentPage { + + public DeploymentPage() { + super(); + } + + public static List<WebElement> getGroupMembersList(String instanceName) { + List<WebElement> propertyRows = null; + clickOnModuleName(instanceName); + propertyRows = getVisibleMembers(); + return propertyRows; + } + + public static void clickOnModuleName(String instanceName) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", instanceName)); + GeneralUIUtils.clickOnElementByText(instanceName); + GeneralUIUtils.ultimateWait(); + } + + public static List<WebElement> getVisibleMembers() { + List<WebElement> instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='hierarchy-module-member-list']")); + for (WebElement instance : instancesFromTable){ + Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); + if (!parentAttributes.toString().contains("hidden")){ + return instance.findElements(By.cssSelector("div[class^='expand-collapse-sub-title']")); + } + } + return null; + } + + public static void clickOnProperties() throws Exception{ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Properties button")); + GeneralUIUtils.clickOnElementByCSS(DataTestIdEnum.DeploymentScreen.BUTTON_PROPERTIES.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public static void clickOnArtifacts() throws Exception{ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Artifacts button")); + GeneralUIUtils.clickOnElementByCSS(DataTestIdEnum.DeploymentScreen.BUTTON_ARTIFACTS.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public static void clickOnSaveButton(){ + clickInDeployment(DataTestIdEnum.DeploymentScreen.SAVE); + GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("popover-inner")); + } + + public static void clickOnCancelButton(){ + clickInDeployment(DataTestIdEnum.DeploymentScreen.CANCEL); + GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("popover-inner")); + } + + public static void clickOnXIcon(){ + clickInDeployment(DataTestIdEnum.DeploymentScreen.X_BUTTON); + GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("popover-inner")); + } + + public static void clickOnEditIcon(){ + clickInDeployment(DataTestIdEnum.DeploymentScreen.PENCIL_ICON); + } + + public static void clickOnProperty(WebElement property) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s propertie ...", property.getText())); + property.click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue()); + } + + private static void clickInDeployment(DataTestIdEnum.DeploymentScreen element){ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s ...", element.getValue())); + GeneralUIUtils.clickOnElementByTestId(element.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public static List<WebElement> getPropertyNames() throws Exception{ + clickOnProperties(); + return GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.PROPERTY_NAMES.getValue()); + } + + public static List<WebElement> getArtifactNames() throws Exception{ + clickOnArtifacts(); + return GeneralUIUtils.getInputElements(DataTestIdEnum.DeploymentScreen.ARTIFACT_NAME.getValue()); + } + + public static String updateModuleName(String currentModuleName, String newModuleName) throws Exception { + GeneralUIUtils.ultimateWait(); + ResourceUIUtils.clickOnElementByText(currentModuleName, null); + GeneralUIUtils.ultimateWait(); + clickOnEditIcon(); + WebElement moduleNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.NAME_INPUT.getValue()); + String oldModuleName = moduleNameField.getAttribute("value"); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating %s module name ...", currentModuleName)); + moduleNameField.clear(); + GeneralUIUtils.ultimateWait(); + moduleNameField.sendKeys(newModuleName); + GeneralUIUtils.ultimateWait(); + clickOnSaveButton(); + String newReconstructedModuleName = reconstructModuleName(currentModuleName.split("\\.\\."), newModuleName); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Name of element instance changed from %s to %s", currentModuleName, newReconstructedModuleName)); + return oldModuleName; + } + + public static String reconstructModuleName(String[] splittedName, String middleName){ + int i = 0; + StringBuilder builder = new StringBuilder(); + for(String s : splittedName) { + if (i == 1){ + builder.append(middleName); + } else { + builder.append(s); + } + if (i < 2 ){ + builder.append(".."); + } + i++; + } + return builder.toString(); + } + + public static List<WebElement> getVisibleModulesService() { + List<WebElement> instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='hierarchy-modules-list']")); + for (WebElement instance : instancesFromTable){ + Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); + if (!parentAttributes.toString().contains("hidden")){ + return instance.findElements(By.cssSelector("span[class^='expand-collapse-title-text']")); + } + } + return null; + } + + public static List<WebElement> getInstanceModulesList(String instanceName) { + List<WebElement> propertyRows = null; + ResourceUIUtils.clickOnElementByText(instanceName, null); + GeneralUIUtils.ultimateWait(); + propertyRows = getVisibleModulesService(); + return propertyRows; + } + + public static String getGroupVersion() throws Exception{ + return GeneralUIUtils.getElementsByCSS("div[data-tests-id='selected-module-version']").get(0).getText(); + } + + public static String getModuleID() throws Exception{ + return GeneralUIUtils.getElementsByCSS("div[data-tests-id='selected-module-group-uuid'] span[class^='small-font']").get(0).getText(); + } + + public static Map<String, HashMap<String, String>> collectMetaDataFromUI() throws Exception{ + ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen(); + Map<String, HashMap<String, String>> deploymentViewMetaData = new HashMap<String, HashMap<String, String>>(); + List<WebElement> moduleRowsFromTable = GeneralUIUtils.getElementsByCSS("span[class^='expand-collapse-title-text']"); + for(WebElement moduleRow :moduleRowsFromTable){ + HashMap<String, String> tempGroupMap = new HashMap<String, String>(); + String moduleRowText = moduleRow.getText(); + GeneralUIUtils.clickOnElementByText(moduleRowText); + tempGroupMap.put("moduleID", getModuleID()); + tempGroupMap.put("version", DeploymentPage.getGroupVersion().split(":")[1].trim()); + deploymentViewMetaData.put(moduleRowText.split("\\.\\.")[1], tempGroupMap); + GeneralUIUtils.clickOnElementByText(moduleRowText); + } + return deploymentViewMetaData; + } + + public static void updateAndCancel(String newModuleName, DataTestIdEnum.DeploymentScreen buttonToClick){ + WebElement moduleNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.NAME_INPUT.getValue()); + String oldModuleName = moduleNameField.getAttribute("value"); + moduleNameField.clear(); + GeneralUIUtils.ultimateWait(); + moduleNameField.sendKeys(newModuleName); + GeneralUIUtils.ultimateWait(); + if (buttonToClick.equals(DataTestIdEnum.DeploymentScreen.X_BUTTON)) + clickOnXIcon(); + else + clickOnCancelButton(); + } + + public static String getPropertyValueFromPropertiesList(String property) throws InterruptedException{ + List<WebElement> propertyDataElements = GeneralUIUtils.getElementsByCSS("div[class^='list-item property-data']"); + for(WebElement propertyDataElement: propertyDataElements){ + WebElement propertyNameElement = GeneralUIUtils.getElementfromElementByCSS(propertyDataElement, DeploymentScreen.PROPERTY_NAMES.getValue()); + if (propertyNameElement.getText().equals(property)){ + WebElement propertyValueElement = GeneralUIUtils.getElementfromElementByCSS(propertyDataElement, String.format("div[data-tests-id='%s']", DeploymentScreen.PROPERTY_SCHEMA_TYPE.getValue())); + return propertyValueElement.getText().trim().split(":")[1].trim(); + } + } + return null; + } + + public static List<WebElement> getPropertyErrorValidationMessdge() throws Exception{ + List<WebElement> propertyErrorElements = GeneralUIUtils.getElementsByCSS("div[class='input-error'] span[class='ng-scope']"); + return propertyErrorElements; + } + + public static boolean isPropertySaveButtonDisabled(){ + WebElement saveButtonElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.SAVE.getValue()); + return GeneralUIUtils.isElementDisabled(saveButtonElement); + } + + + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GeneralPageElements.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GeneralPageElements.java new file mode 100644 index 0000000000..04e3a8bb28 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GeneralPageElements.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.List; +import java.util.function.Supplier; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.aventstack.extentreports.Status; + +public class GeneralPageElements { + + public GeneralPageElements() { + super(); + } + + public static ResourceLeftMenu getLeftMenu() { + return new ResourceLeftMenu(); + } + + public static void clickOKButton() { + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the OK button"); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); + GeneralUIUtils.waitForLoader(); + } + + public static void clickCreateButton() { + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the CREATE/UPDATE button."); + GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); + ExtentTestActions.log(Status.INFO, "Succeeded."); + } + + public static void clickCreateButton(int timeout) { + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the CREATE/UPDATE button"); + GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue(), timeout); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); + } + + public static void clickUpdateButton(){ + clickCreateButton(); + } + + public static void clickCheckinButton(String componentName) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the CHECKIN button"); + GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.ACCEP_TESTING_MESSAGE.getValue()).sendKeys("Checkin " + componentName); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue(), 60); + GeneralUIUtils.ultimateWait(); + } + + public static void clickSubmitForTestingButton(String componentName) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the submiting for testing button"); + GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.SUBMIT_FOR_TESTING_BUTTON.getValue()); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.SUMBIT_FOR_TESTING_MESSAGE.getValue()).sendKeys("Submit for testing " + componentName); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue(), 60); + GeneralUIUtils.ultimateWait();; + } + + public static void clickCheckoutButton() throws Exception{ + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on CHECKOUT button ..."); + GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CHECKOUT_BUTTON.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public static void clickDeleteVersionButton() throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on DELETE VERSION button ..."); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.DELETE_VERSION_BUTTON.getValue()); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.OK.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public static void clickRevertButton() throws Exception{ + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on REVERT button ..."); + GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.REVERT_BUTTON.getValue()); + } + + public static String getLifeCycleState() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()).getText(); + } + + public static void selectVersion(String version) { + GeneralUIUtils.getSelectList(version, DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public static List<WebElement> getElemenetsFromTable() { + GeneralUIUtils.ultimateWait();; + return GeneralUIUtils.getElemenetsFromTable(By.className("flex-container")); + } + + public static boolean checkElementsCountInTable(int expectedElementsCount) { + return checkElementsCountInTable(expectedElementsCount, () -> getElemenetsFromTable()); + } + + + public static void clickTrashButtonAndConfirm() throws InterruptedException{ + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on TRASH button ..."); + GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.DELETE_VERSION_BUTTON.getValue()); + clickOKButton(); + } + + public static boolean checkElementsCountInTable(int expectedElementsCount, Supplier<List<WebElement>> func) { + SetupCDTest.getExtendTest().log(Status.INFO, "Checking the number of elements in the table; should be " + (expectedElementsCount - 1)); +// int maxWaitingPeriodMS = 10*1000; +// int napPeriodMS = 200; +// int sumOfWaiting = 0; +// List<WebElement> elements = null; +// boolean isKeepWaiting = false; +// while (!isKeepWaiting) { +// GeneralUIUtils.sleep(napPeriodMS); +// sumOfWaiting += napPeriodMS; +// elements = func.get(); +// isKeepWaiting = (expectedElementsCount == elements.size()); +// if (sumOfWaiting > maxWaitingPeriodMS) +// return false; +// } + GeneralUIUtils.ultimateWait(); + return true; + } + + public static void clickDeleteFile() throws Exception{ + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on delete file X-button ..."); + GeneralUIUtils.clickOnAreaJS(GeneralUIUtils.getWebElementBy + (By.cssSelector("div[class='i-sdc-form-file-upload-x-btn']"))); + GeneralUIUtils.ultimateWait();; + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GovernorOperationPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GovernorOperationPage.java new file mode 100644 index 0000000000..ff964e3a01 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GovernorOperationPage.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; + +import com.aventstack.extentreports.Status; + +public class GovernorOperationPage { + + public GovernorOperationPage() { + super(); + } + + public static void approveSerivce(String serviceName) { + SetupCDTest.getExtendTest().log(Status.INFO, "Approving the distrbution of the service " + serviceName); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.APPROVE.getValue()).click(); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.APPROVE_MESSAGE.getValue()) + .sendKeys("service " + serviceName + " tested successfuly"); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.OK.getValue()).click(); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()); + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HomePage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HomePage.java new file mode 100644 index 0000000000..84451dc905 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HomePage.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.io.File; +import java.util.List; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.MainMenuButtonsFromInsideFrame; +import org.openecomp.sdc.ci.tests.utilities.DownloadManager; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +public class HomePage extends GeneralPageElements { + + public HomePage() { + super(); + } + + public static void showVspRepository(){ + GeneralUIUtils.waitForElementInVisibilityBy(By.className("ui-notification"), 30); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.MainMenuButtons.REPOSITORY_ICON.getValue()); + } + + public static boolean searchForVSP(String vspName){ + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ImportVfRepository.SEARCH.getValue()).sendKeys(vspName); + return checkElementsCountInTable(2); + } + + public static void importVSP(String vspName){ + HomePage.showVspRepository(); + boolean vspFound = HomePage.searchForVSP(vspName); + if (vspFound){ + List<WebElement> elemenetsFromTable = getElemenetsFromTable(); +// GeneralUIUtils.waitForLoader(); + WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 30); + WebElement findElement = wait.until(ExpectedConditions.visibilityOf(elemenetsFromTable.get(1))); + findElement.click(); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.IMPORT_VSP.getValue()); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()); + GeneralUIUtils.waitForLoader(60*10); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); + } + } + + + public static boolean navigateToHomePage() { + try{ + System.out.println("Searching for reporsitory icon."); + WebElement repositoryIcon = GeneralUIUtils.getInputElement("repository-icon"); + if (repositoryIcon != null){ + return true; + } + else{ + GeneralUIUtils.ultimateWait(); + List<WebElement> homeButtons = GeneralUIUtils.getElemenetsFromTable(By.xpath("//a[contains(.,'HOME')]")); + if (homeButtons.size() != 0){ + for (WebElement home : homeButtons){ + if (home.isDisplayed()){ + home.click(); + System.out.println("Clicked on home button"); + break; + } + } + GeneralUIUtils.closeErrorMessage(); + WebElement homeButton = GeneralUIUtils.getInputElement(DataTestIdEnum.MainMenuButtons.HOME_BUTTON.getValue()); + return homeButton.isDisplayed(); + } + + } + } + catch(Exception innerException){ + System.out.println("Can't click on home button."); + return false; + } + return false; + } + + public static File downloadVspCsarToDefaultDirectory(String vspName) throws Exception { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + DownloadManager.downloadCsarByNameFromVSPRepository(vspName, ""); + File latestFilefromDir = FileHandling.getLastModifiedFileFromDir(); + return latestFilefromDir; + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/IconPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/IconPage.java new file mode 100644 index 0000000000..fd9befa148 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/IconPage.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; + +public class IconPage extends GeneralPageElements { + + public IconPage() { + super(); + } + + public static void clickOnIcon(ResourceCategoryEnum iconName) { + GeneralUIUtils.getWebElementByTestID(iconStringBuilder(iconName) + DataTestIdEnum.ServiceMetadataEnum.ICON.getValue()) + .click(); + } + + private static String iconStringBuilder(ResourceCategoryEnum icon) { + String iconName = icon.getSubCategory(); + String[] splitedIconName = iconName.split(" "); + splitedIconName[0] = splitedIconName[0].toLowerCase(); + + StringBuilder sb = new StringBuilder(); + for (String word : splitedIconName) { + sb.append(word); + } + + return sb.toString(); + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InformationalArtifactPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InformationalArtifactPage.java new file mode 100644 index 0000000000..9916292e5b --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InformationalArtifactPage.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.List; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; +import org.openqa.selenium.WebElement; + +import com.aventstack.extentreports.Status; + +public class InformationalArtifactPage extends DeploymentArtifactPage { + + public InformationalArtifactPage() { + super(); + } + + public static void clickAddNewArtifact() { + addNewArtifact(ArtifactGroupTypeEnum.INFORMATIONAL); + } + + public static String getArtifactDescription(String artifactLabel) throws Exception { + InformationalArtifactPage.clickOnArtifact(artifactLabel); + String artifactDesc = GeneralUIUtils.getWebElementByTestID( + artifactLabel + DataTestIdEnum.ArtifactPageEnum.GET_INFORMATIONAL_ARTIFACT_DESCRIPTION.getValue()) + .getText(); + InformationalArtifactPage.clickOnArtifact(artifactLabel); // close artifact + return artifactDesc; + } + + public static List<WebElement> getElemenetsFromTable() { + return GeneralUIUtils.getWebElementsListByTestID("InformationalArtifactRow"); + } + + public static WebElement clickOnArtifact(String artifactLabel) throws Exception { + try{ + WebElement artifact = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.ARTIFACT_NAME.getValue() + artifactLabel); + artifact.click(); + GeneralUIUtils.waitForLoader(); + return artifact; + } + catch(Exception e){ + throw new Exception("Artifact " + artifactLabel + "is not found"); + } + } + + + public static void clickDeleteArtifact(String artifactLabel) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Deleting %s Artefact ",artifactLabel)); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DELETE_ARTIFACT.getValue() + artifactLabel).click(); + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InputsPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InputsPage.java new file mode 100644 index 0000000000..b977b263a0 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InputsPage.java @@ -0,0 +1,158 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.List; +import java.util.stream.Collectors; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.InputsScreenService; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.testng.TestException; + +import com.aventstack.extentreports.Status; + +public class InputsPage extends GeneralPageElements { + + public InputsPage() { + super(); + + } + + public static List<WebElement> getInstancePropertiesList(String instanceName) { + List<WebElement> propertyRows = null; + GeneralUIUtils.clickOnElementByText(instanceName); + GeneralUIUtils.ultimateWait(); + propertyRows = getVisibleProperites(); + return propertyRows; + } + + public static List<WebElement> getVisibleProperites() { + List<WebElement> instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='vf-instance-list']")); + for (WebElement instance : instancesFromTable){ + Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); + if (!parentAttributes.toString().contains("hidden")){ + return instance.findElements(By.className("property-row")); + } + } + return null; + } + + public static void addInputToService(String VFInstanceName, String propertyName) throws Exception{ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding property %s from VF instance %s to Service", propertyName, VFInstanceName)); + List<WebElement> instaceInputs = getInstanceInputsList(VFInstanceName); + for(WebElement instancInput: instaceInputs){ + String actualPropertyName = instancInput.findElement(By.className("title-text")).getText(); + if (actualPropertyName.equals(propertyName) && clickOnVFInputCheckbox(instancInput)){ + clickOnAddInputButton(); + } + } + } + + public static List<WebElement> getInstanceInputsList(String instanceName) { + List<WebElement> inputRows = null; + GeneralUIUtils.clickOnElementByText(instanceName); + GeneralUIUtils.ultimateWait(); + inputRows = getVisibleInputs(inputRows); + return inputRows; + } + + public static List<WebElement> getVisibleInputs(List<WebElement> inputRows) { + List<WebElement> instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='vf-instance-list']")); + for (WebElement instance : instancesFromTable){ + Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); + if (!parentAttributes.toString().contains("hidden")){ + inputRows = instance.findElements(By.className("input-row")); + break; + } + } + return inputRows; + } + + public static void clickOnAddInputButton(){ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Add Input aka Greater than symbol button")); + GeneralUIUtils.clickOnElementByTestId(InputsScreenService.ADD_SELECTED_INPUTS_BTN.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public static boolean clickOnVFInputCheckbox(WebElement instancInput){ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on VF instance input checkbox")); + instancInput.findElement(By.className("tlv-checkbox-label")).click(); + GeneralUIUtils.ultimateWait(); + return instancInput.findElement(By.className("tlv-checkbox-i")).getAttribute("class").contains("ng-not-empty"); + } + + public static WebElement getServiceInput(String VFInstanceName, String propertyName) throws Exception{ + String expectedInputName = String.format("%s_%s", VFInstanceName.replace(" ", "").toLowerCase(), propertyName); + List<WebElement> inputsFromTable = GeneralUIUtils.getElementsByCSS(InputsScreenService.SERVICE_INPUT_ROW.getValue()); + for(WebElement inputFromTable: inputsFromTable){ + String actualInputName = inputFromTable.findElement(By.className("title-text")).getText(); + if(actualInputName.equals(expectedInputName)){ + return inputFromTable; + } + } + throw new TestException(String.format("%s input don't exist", expectedInputName)); + } + + public static void deleteServiceInput(String VFInstanceName, String propertyName) throws Exception{ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Deleting property %s in VF instance %s ", propertyName, VFInstanceName)); + WebElement serviceInput = getServiceInput(VFInstanceName, propertyName); + serviceInput.findElement(By.cssSelector(InputsScreenService.DELETE_INPUT_BTN.getValue())).click(); + GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on OK button ")); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.OK.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public static List<String> getVFCInstancesNamesFromTable() throws Exception{ + WebElement inputsTable = getInputsTable("VFC "); + return inputsTable.findElements(By.cssSelector("span[class^='title-text']")).stream(). + map(e -> e.getText()). + collect(Collectors.toList()); + } + + public static WebElement getInputsTable(String tableName) throws Exception{ + List<WebElement> tableElements = GeneralUIUtils.getElementsByCSS("div.table"); + for(WebElement tableElement: tableElements){ + String tableTitle = GeneralUIUtils.getElementfromElementByCSS(tableElement, "div.table-header").getText(); + if (tableTitle.contains(tableName)){ + return tableElement; + } + } + throw new TestException(String.format("Can't find %s table", tableName)); + } + + public static void clickOnProperty(String propertyName) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on property %s ", propertyName)); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_NAME.getValue() + propertyName); + GeneralUIUtils.ultimateWait(); + } + + + + + + + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/OpsOperationPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/OpsOperationPage.java new file mode 100644 index 0000000000..82171b8de9 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/OpsOperationPage.java @@ -0,0 +1,156 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.List; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.StepsEnum; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import com.aventstack.extentreports.Status; + +public class OpsOperationPage { + + public OpsOperationPage() { + super(); + } + + public static void distributeService() { + SetupCDTest.getExtendTest().log(Status.INFO, "Distributing"); + clickOnButton(DataTestIdEnum.DistributionChangeButtons.DISTRIBUTE); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.MONITOR.getValue()); + } + + public static void displayMonitor() { + GeneralUIUtils.moveToStep(StepsEnum.MONITOR); + } + + public static void re_distributeService() { + SetupCDTest.getExtendTest().log(Status.INFO, "Redistributing..."); + clickOnButton(DataTestIdEnum.DistributionChangeButtons.RE_DISTRIBUTE); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.MONITOR.getValue()); + } + + private static void clickOnButton(DataTestIdEnum.DistributionChangeButtons button) { + GeneralUIUtils.getWebElementByTestID(button.getValue()).click(); + GeneralUIUtils.waitForLoader(); + } + + public static List<WebElement> getRowsFromMonitorTable() { + SetupCDTest.getExtendTest().log(Status.INFO, "Counting the rows from the distribution table"); + GeneralPageElements.checkElementsCountInTable(1, () -> GeneralUIUtils.getWebElementsListByTestID("ditributionTable")); + List<WebElement> distributionRecords = GeneralUIUtils.getWebElementsListByTestID("ditributionTable"); + List<WebElement> findElements = distributionRecords.get(0).findElements(By.className("w-sdc-distribute-parent-block")); + return findElements; + } + + public static void showDistributionStatus(int rowIndex) { + GeneralUIUtils.getWebElementByTestID("ShowRecordButton_" + String.valueOf(rowIndex)).click(); + GeneralUIUtils.waitForLoader(); + } + + public static String getTotalArtifactsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("totalArtifacts_" + String.valueOf(rowIndex)).getText(); + } + + public static String getNotifiedArtifactsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("notified_" + String.valueOf(rowIndex)).getText(); + } + + public static String getDownloadedArtifactsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("downloaded_" + String.valueOf(rowIndex)).getText(); + } + + public static String getDeployedArtifactsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("deployed_" + String.valueOf(rowIndex)).getText(); + } + + public static String getNotNotifiedArtifactsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("NotNotified_" + String.valueOf(rowIndex)).getText(); + } + + public static String getErrorsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("errors_" + String.valueOf(rowIndex)).getText(); + } + + public static void clickRefreshTableButton(int rowIndex) { + GeneralUIUtils.getWebElementByTestID("refreshButton").click(); + // wait until total artifacts field disappear + WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 90); + wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + "totalArtifacts_" + String.valueOf(rowIndex) + "']"))); + } + + public static void waitUntilArtifactsDistributed(int rowIndex) throws Exception { + waitUntilArtifactsDistributed("0", 0); + } + + public static void waitUntilArtifactsDistributed(String expectedArtifactsSum, int rowIndex) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Waiting until all artifacts are distributed"); + boolean isKeepWaiting = true; + int maxWaitingPeriodMS = 5 * 60 * 1000; + int sumWaitingTime = 0; + int napPeriod = 10000; + while (isKeepWaiting) { + showDistributionStatus(rowIndex); + String actualTotalArtifactsSize = getTotalArtifactsSum(rowIndex); + String actualNotifiedArtifactsSize = getNotifiedArtifactsSum(rowIndex); + String actualDownloadedArtifactsSize = getDownloadedArtifactsSum(rowIndex); + String actualDeployedArtifactsSize = getDeployedArtifactsSum(rowIndex); + String actualNotNotifedArtifactsSize = getNotNotifiedArtifactsSum(rowIndex); + isKeepWaiting = !actualTotalArtifactsSize.equals(actualDownloadedArtifactsSize) + || !actualTotalArtifactsSize.equals(actualNotifiedArtifactsSize) + || !actualTotalArtifactsSize.equals(actualDeployedArtifactsSize) + || actualTotalArtifactsSize.equals("0") || actualDownloadedArtifactsSize.equals("0") + || actualNotifiedArtifactsSize.equals("0") || actualDeployedArtifactsSize.equals("0"); + + if (isKeepWaiting) { + + if (Integer.parseInt(actualNotNotifedArtifactsSize) > 1) { + SetupCDTest.getExtendTest().log(Status.INFO, "Some artifacts are not notified"); + isKeepWaiting = false; + throw new Exception("Some artifacts are not notified..."); + } + + GeneralUIUtils.sleep(napPeriod); + sumWaitingTime += napPeriod; + + if (sumWaitingTime > maxWaitingPeriodMS) { + SetupCDTest.getExtendTest().log(Status.INFO, "Not all artifacts are displayed"); + isKeepWaiting = false; + throw new Exception(String.format("Not all artifacts are displayed withing %s seconds", + String.valueOf(maxWaitingPeriodMS / 1000))); + } + + clickRefreshTableButton(rowIndex); + } + } + + SetupCDTest.getExtendTest().log(Status.INFO, "All artifacts were successfully distributed"); + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductGeneralPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductGeneralPage.java new file mode 100644 index 0000000000..3bec4f636c --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductGeneralPage.java @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.ArrayList; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.aventstack.extentreports.Status; + +/** + * @author al714h + * + */ + +public class ProductGeneralPage extends ResourceGeneralPage { + + public ProductGeneralPage() { + super(); + } + + public static ProductLeftMenu getProductLeftMenu() { + return new ProductLeftMenu(); + } + + public static void defineName(String productName) { + WebElement productNameTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PRODUCT_NAME.getValue()); + productNameTextbox.clear(); + productNameTextbox.sendKeys(productName); + } + + public static void defineFullName(String productFullName) { + WebElement productFullNameTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.FULL_NAME.getValue()); + productFullNameTextbox.clear(); + productFullNameTextbox.sendKeys(productFullName); + } + + public static void defineProjectCode(String pmat) { + WebElement pmattTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PROJECT_CODE.getValue()); + pmattTextbox.clear(); + pmattTextbox.sendKeys(pmat); + } + + public static String getPmattText(){ + return getPmattField().getAttribute("value"); + } + + public static String[] getTags(){ + return ResourceGeneralPage.getElementsFromTagsTable().stream().map(WebElement::getText).toArray(String[]::new); + } + + private static WebElement getPmattField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PROJECT_CODE.getValue()); + } + + public static void deleteOldTags(ProductReqDetails product){ + // Delete tag elements + int i = GeneralUIUtils.getWebElementsListByTestID("i-sdc-tag-delete").size(); + while (i > 0){ + GeneralUIUtils.getWebElementByTestID("i-sdc-tag-delete").click(); + i--; + } + + product.setTags(new ArrayList<String>()); + } + + public static void clickAddWorkflow (){ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding workflow...")); + GeneralUIUtils.clickOnElementByText("Add Workflow"); + } + + public static void fillAndAddNewWorkflow(String name, String description ) throws InterruptedException{ + GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling name field with %s", name)); + insertText(name, "label + input"); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling description filed with %s", name)); + insertText(description,"label + textarea"); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking save button ")); + clickSave(); + } + + public static void insertText(String artifactDescriptoin, String element) throws InterruptedException { + GeneralUIUtils.getElementsByCSS("div[class='modal-content']"); + WebElement artifactDescriptionTextbox = GeneralUIUtils.getWebElementBy(By.cssSelector(element)); + artifactDescriptionTextbox.clear(); + artifactDescriptionTextbox.sendKeys(artifactDescriptoin); + GeneralUIUtils.ultimateWait(); + } + + public static void clickSave() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save button")); + GeneralUIUtils.clickOnElementByText("Save"); + GeneralUIUtils.ultimateWait(); + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductLeftMenu.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductLeftMenu.java new file mode 100644 index 0000000000..2972e59618 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductLeftMenu.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.StepsEnum; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; + +/** + * @author al714h + * + */ + +public class ProductLeftMenu implements ComponentLeftMenu { + + public void moveToGeneralScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.GENERAL); + } + + public void moveToIconScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.ICON); + } + + public void moveToCompositionScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); + } + + public void moveToHierarchyScreen() { + GeneralUIUtils.moveToStep(StepsEnum.HIERARCHY); + } +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertiesPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertiesPage.java new file mode 100644 index 0000000000..4899ab15af --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertiesPage.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.List; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.aventstack.extentreports.Status; + +public class PropertiesPage extends GeneralPageElements { + + public PropertiesPage() { + super(); + } + + public static List<WebElement> getElemenetsFromTable() { + return GeneralUIUtils.getInputElements(DataTestIdEnum.PropertiesPageEnum.PROPERTY_ROW.getValue()); + } + + public static void clickAddPropertyArtifact() { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.ADD_NEW_PROPERTY.getValue()).click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue()); + } + + public static void clickEditPropertyArtifact(String propertyName) { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.EDIT_PROPERTY.getValue() + propertyName).click(); + } + + public static void clickDeletePropertyArtifact(String propertyName) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Delete property %s", propertyName)); + GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propertyName); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPageEnum.DELETE_PROPERTY.getValue() + propertyName); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); + GeneralUIUtils.waitForElementInVisibilityBy(By.className("w-sdc-modal-confirmation"), 10); + } + + public static void clickOnProperty(String propertyName) { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propertyName).click(); + } + + public static PropertyPopup getPropertyPopup() { + return new PropertyPopup(); + } + + public static boolean verifyTotalProperitesField(int count){ + String totalPropertiesCount = GeneralUIUtils.getWebElementBy(By.id("properties-count")).getText(); + return ("Total Properties: " + count).equals(totalPropertiesCount); + } + + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertyPopup.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertyPopup.java new file mode 100644 index 0000000000..5052406d4e --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertyPopup.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.Select; + +import com.aventstack.extentreports.Status; + +public class PropertyPopup { + + + public PropertyPopup() { + } + + public boolean getPopupForm(){ + return GeneralUIUtils.waitForElementInVisibilityByTestId(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue(), 60); + } + + public void insertPropertyName(String name) { + WebElement propertyNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_NAME.getValue()); + propertyNameField.clear(); + propertyNameField.sendKeys(name); + } + + public void insertPropertyDefaultValue(String value) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Inserting to property default value: %s ", value)); + WebElement selectedType = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue())).getFirstSelectedOption(); + if(selectedType.getText().equals("boolean")) { + GeneralUIUtils.getSelectList(value, DataTestIdEnum.PropertiesPopupEnum.PROPERTY_BOOLEAN_VALUE.getValue()); + } else { + WebElement propertyValue = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_VALUE.getValue()); + propertyValue.clear(); + propertyValue.sendKeys(value); + } + + GeneralUIUtils.ultimateWait(); + } + + public void insertPropertyDescription(String description) { + WebElement propertyDescription = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_DESCRIPTION.getValue()); + propertyDescription.clear(); + propertyDescription.sendKeys(description); + } + + public void selectPropertyType(String propertyType) { + boolean isEntrySchemaDisplayed; + try{ + GeneralUIUtils.getSelectList(propertyType, DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue()); + isEntrySchemaDisplayed = GeneralUIUtils.getDriver().findElement(By.xpath(DataTestIdEnum.PropertiesPopupEnum.ENTRY_SCHEMA.getValue())).isDisplayed(); + if (isEntrySchemaDisplayed){ + PropertiesPage.getPropertyPopup().selectEntrySchema(propertyType); + } + } + catch(NoSuchElementException e){ + + } + } + + public void selectEntrySchema(String propertyType){ + GeneralUIUtils.getSelectList(propertyType, DataTestIdEnum.PropertiesPopupEnum.ENTRY_SCHEMA.getValue()); + } + + public void clickAdd() { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.ADD.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public void clickSave() { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.SAVE.getValue()); + getPopupForm(); + } + + public void clickCancel() { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.CANCEL.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public void clickDone() { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.DONE.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public void selectPropertyRadioButton(String propertyName) { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_RADIO_BUTTON_CONTAINER.getValue() + propertyName).findElement(By.className(DataTestIdEnum.PropertiesPopupEnum.RADIO_BUTTON_CLASS.getValue())).click(); + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceGeneralPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceGeneralPage.java new file mode 100644 index 0000000000..1412a4b969 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceGeneralPage.java @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.ArrayList; +import java.util.List; + +import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; + + +public class ResourceGeneralPage extends GeneralPageElements { + + public ResourceGeneralPage() { + super(); + } + + public static WebElement getNameField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.RESOURCE_NAME.getValue()); + } + + public static WebElement getDescriptionField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.DESCRIPTION.getValue()); + } + + public static String getCategoryDataTestsIdAttribute() { + return DataTestIdEnum.ResourceMetadataEnum.CATEGORY.getValue(); + } + + public static WebElement getVendorNameField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_NAME.getValue()); + } + + public static WebElement getVendorReleaseField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_RELEASE.getValue()); + } + + public static WebElement getTagsField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS.getValue()); + } + + public static WebElement getContactIdField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.CONTACT_ID.getValue()); + } + + /***************************************************************/ + + public static String getNameText() { + return getNameField().getAttribute("value"); + } + + public static void defineName(String resourceName) { + WebElement resourceNameTextbox = getNameField(); + resourceNameTextbox.clear(); + resourceNameTextbox.sendKeys(resourceName); + } + + public static void defineNameWithPaste() { + defineTextBoxWithPaste(getNameField()); + } + + public static String getDescriptionText() { + return getDescriptionField().getAttribute("value"); + } + + public static void defineDescription(String description) { + WebElement descriptionTextbox = getDescriptionField(); + descriptionTextbox.clear(); + descriptionTextbox.sendKeys(description); + } + + public static void defineDescriptionWithPaste() { + defineTextBoxWithPaste(getDescriptionField()); + } + + public static String getVendorNameText() { + return getVendorNameField().getAttribute("value"); + } + + public static void defineVendorName(String vendorName) { + WebElement vendorNameTextbox = getVendorNameField(); + vendorNameTextbox.clear(); + vendorNameTextbox.sendKeys(vendorName); + } + + public static void defineVendorNameWithPaste() { + defineTextBoxWithPaste(getVendorNameField()); + } + + public static String getVendorReleaseText() { + return getVendorReleaseField().getAttribute("value"); + } + + public static void defineVendorRelease(String vendorRelease) { + WebElement vendorReleaseTextbox = getVendorReleaseField(); + vendorReleaseTextbox.clear(); + vendorReleaseTextbox.sendKeys(vendorRelease); + } + + public static void defineVendorReleaseWithPaste() { + defineTextBoxWithPaste(getVendorReleaseField()); + } + + public static void defineTag(String resourceTags) { + WebElement tagTextbox = getTagsField(); + tagTextbox.clear(); + tagTextbox.sendKeys(resourceTags); + tagTextbox.sendKeys(Keys.ENTER); + } + + public static void defineTagsList(ComponentReqDetails component, String[] tags) { + List<String> taglist = new ArrayList<String>(); + WebElement resourceTagsTextbox = getTagsField(); + for (String tag : tags) { + resourceTagsTextbox.clear(); + resourceTagsTextbox.sendKeys(tag); + GeneralUIUtils.sleep(500); + resourceTagsTextbox.sendKeys(Keys.ENTER); + taglist.add(tag); + } + component.getTags().addAll(taglist); + } + + public static void defineTagsListWithPaste() { + List<String> taglist = new ArrayList<String>(); + WebElement resourceTagsTextbox = getTagsField(); + defineTextBoxWithPaste(resourceTagsTextbox); + resourceTagsTextbox.sendKeys(Keys.ENTER); + } + + public static void defineCategory(String category) { + GeneralUIUtils.getSelectList(category, getCategoryDataTestsIdAttribute()); + } + + public static String getContactIdText() { + return getContactIdField().getAttribute("value"); + } + + public static void defineContactId(String userId) { + WebElement contactIdTextbox = getContactIdField(); + contactIdTextbox.clear(); + contactIdTextbox.sendKeys(userId); + GeneralUIUtils.waitForLoader(); + } + + public static List<WebElement> getElementsFromTagsTable(){ + return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS_TABLE.getValue()); + } + + public static void defineTextBoxWithPaste(WebElement textBox) { + textBox.clear(); + textBox.sendKeys(Keys.CONTROL + "v"); + GeneralUIUtils.ultimateWait(); + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceLeftMenu.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceLeftMenu.java new file mode 100644 index 0000000000..a128aefdc8 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceLeftMenu.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.StepsEnum; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; + +public class ResourceLeftMenu implements ComponentLeftMenu { + + public void moveToGeneralScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.GENERAL); + } + + public void moveToIconScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.ICON); + } + + public void moveToDeploymentArtifactScreen() { + GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); + } + + public void moveToInformationalArtifactScreen() { + GeneralUIUtils.moveToStep(StepsEnum.INFORMATION_ARTIFACT); + } + + public void moveToPropertiesScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.PROPERTIES); + } + + public void moveToCompositionScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); + } + + public void moveToActivityLogScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.ACTIVITY_LOG); + } + + public void moveToDeploymentViewScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_VIEW); + } + + public void moveToToscaArtifactsScreen() { + GeneralUIUtils.moveToStep(StepsEnum.TOSCA_ARTIFACTS); + } + + public void moveToInputsScreen() { + GeneralUIUtils.moveToStep(StepsEnum.INPUTS); + } +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceGeneralPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceGeneralPage.java new file mode 100644 index 0000000000..0394978261 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceGeneralPage.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.util.ArrayList; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.aventstack.extentreports.Status; + +public class ServiceGeneralPage extends ResourceGeneralPage { + + public ServiceGeneralPage() { + super(); + } + + public static ServiceLeftMenu getServiceLeftMenu() { + return new ServiceLeftMenu(); + } + + public static void defineName(String serviceName) { + WebElement serviceNameTextbox = GeneralUIUtils + .getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.SERVICE_NAME.getValue()); + serviceNameTextbox.clear(); + serviceNameTextbox.sendKeys(serviceName); + } + + public static void defineProjectCode(String pmat) { + WebElement projectCodeTextbox = GeneralUIUtils + .getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.PROJECT_CODE.getValue()); + projectCodeTextbox.clear(); + projectCodeTextbox.sendKeys(pmat); + } + + public static String getProjectCodeText(){ + return getProjectCodeField().getAttribute("value"); + } + + public static String[] getTags(){ + return ResourceGeneralPage.getElementsFromTagsTable().stream().map(WebElement::getText).toArray(String[]::new); + } + + private static WebElement getProjectCodeField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.PROJECT_CODE.getValue()); + } + + public static void deleteOldTags(ServiceReqDetails service){ + // Delete tag elements + int i = GeneralUIUtils.getWebElementsListByTestID("i-sdc-tag-delete").size(); + while (i > 0){ + GeneralUIUtils.getWebElementByTestID("i-sdc-tag-delete").click(); + i--; + } + + service.setTags(new ArrayList<String>()); + } + + public static String getCategoryText() { + return GeneralUIUtils.getSelectedElementFromDropDown(getCategoryDataTestsIdAttribute()).getText(); + } + + public static void clickAddWorkflow (){ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding workflow...")); + GeneralUIUtils.clickOnElementByText("Add Workflow"); + } + + public static void fillAndAddNewWorkflow(String name, String description ) throws InterruptedException{ + GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling name field with %s", name)); + insertText(name, "label + input"); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling description filed with %s", name)); + insertText(description,"label + textarea"); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking save button ")); + clickSave(); + } + + public static void insertText(String artifactDescriptoin, String element) throws InterruptedException { + GeneralUIUtils.getElementsByCSS("div[class='modal-content']"); + WebElement artifactDescriptionTextbox = GeneralUIUtils.getWebElementBy(By.cssSelector(element)); + artifactDescriptionTextbox.clear(); + artifactDescriptionTextbox.sendKeys(artifactDescriptoin); + GeneralUIUtils.ultimateWait(); + } + + public static void clickSave() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save button")); + GeneralUIUtils.clickOnElementByText("Save"); + GeneralUIUtils.ultimateWait(); + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceLeftMenu.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceLeftMenu.java new file mode 100644 index 0000000000..127ada2309 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceLeftMenu.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.StepsEnum; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; + +public class ServiceLeftMenu implements ComponentLeftMenu { + + public void moveToManagmentWorkflow() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.MANAGEMENT_WORKFLOW); + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/TesterOperationPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/TesterOperationPage.java new file mode 100644 index 0000000000..d9ef375d17 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/TesterOperationPage.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; + +import com.aventstack.extentreports.Status; + +public class TesterOperationPage { + + public TesterOperationPage() { + super(); + } + + public static void certifyComponent(String componentName) throws Exception{ + clickStartTestingButton(); + clickAccpetCertificationButton(componentName); + } + + public static void clickAccpetCertificationButton(String componentName) throws Exception { + ExtentTestActions.log(Status.INFO, "Accepting certifiction of " + componentName); + String actionDuration = GeneralUIUtils.getActionDuration(() -> + { + try { + clickAccpetCertificationButtonWithoutDuration(componentName); + } catch (Exception e) { + e.printStackTrace(); + } + }); + ExtentTestActions.log(Status.INFO, componentName + " is certifed", actionDuration); + + } + + public static void clickStartTestingButton() throws Exception{ + ExtentTestActions.log(Status.INFO, "Starting to test"); + String actionDuration = GeneralUIUtils.getActionDuration(() -> { + try { + clickStartTestingButtonWithoutDuration(); + } catch (Exception e) { + e.printStackTrace(); + } + }); + ExtentTestActions.log(Status.INFO, "Ready for certification", actionDuration); + } + + + private static void certifyComponentWithoutDuration(String componentName) throws Exception { + clickStartTestingButtonWithoutDuration(); + clickAccpetCertificationButtonWithoutDuration(componentName); + } + + + private static void clickAccpetCertificationButtonWithoutDuration(String componentName) throws Exception { + try{ + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.LifeCyleChangeButtons.ACCEPT.getValue()); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.ACCEP_TESTING_MESSAGE.getValue()).sendKeys(componentName + " tested successfuly"); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.sleep(2000); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()); + } + catch (Exception e){ + throw new Exception("Accepting certification of " + componentName + " falied"); + } + } + + private static void clickStartTestingButtonWithoutDuration() throws Exception { + try{ + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.LifeCyleChangeButtons.START_TESTING.getValue()); +// GeneralUIUtils.ultimateWait(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.LifeCyleChangeButtons.ACCEPT.getValue()); +// GeneralUIUtils.ultimateWait(); +// GeneralUIUtils.sleep(1000); + } + catch (Exception e){ + throw new Exception("Start testing falied"); + } + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ToscaArtifactsPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ToscaArtifactsPage.java new file mode 100644 index 0000000000..077ccacde1 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ToscaArtifactsPage.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.WebElement; + +public class ToscaArtifactsPage extends DeploymentArtifactPage { + + public ToscaArtifactsPage() { + + } + + public static String getArtifactName(int row){ + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_NAME.getValue() + row).getText(); + } + + public static String getArtifactType(int row){ + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_TYPE.getValue() + row).getText(); + } + + public static String getArtifactVersion(int row){ + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_VERSION.getValue() + row).getText(); + } + + public static WebElement getArtifactDetails(int row){ + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_DETAILS.getValue() + row); + } + + public static void downloadCsar() { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ToscaArtifactsScreenEnum.DOWNLOAD_CSAR.getValue()); + GeneralUIUtils.ultimateWait(); + } + +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UploadArtifactPopup.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UploadArtifactPopup.java new file mode 100644 index 0000000000..e97f3feb62 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UploadArtifactPopup.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.pages; + +import java.io.File; + +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.Select; +import org.testng.TestException; + +import com.aventstack.extentreports.Status; + +public class UploadArtifactPopup { + + boolean isCompositionPage; + + public UploadArtifactPopup(boolean isCompositionPage) { + super(); + this.isCompositionPage = isCompositionPage; + } + + public UploadArtifactPopup() { + super(); + } + + public WebElement getArtifactDescriptionWebElement(){ + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_DESCRIPTION.getValue()); + } + + public void loadFile(String path, String filename) { + final WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPopup.BROWSE.getValue()); +// browseWebElement.sendKeys(path + filename); + browseWebElement.sendKeys(path + File.separator + filename); + GeneralUIUtils.ultimateWait(); + +// if (!browseWebElement.getAttribute("value").equals(filename)) +// { +// throw new TestException("File named " + filename + " does not presented"); +// } + } + + + + public void insertDescription(String artifactDescriptoin) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Changing artifact description to: %s", artifactDescriptoin)); + WebElement artifactDescriptionTextbox = getArtifactDescriptionWebElement(); + artifactDescriptionTextbox.clear(); + artifactDescriptionTextbox.sendKeys(artifactDescriptoin); + + GeneralUIUtils.ultimateWait();; + } + + public Select defineArtifactLabel(String requiredArtifactLabel) { + Select selectList = null; + WebElement artifactLabelWebElement = null; + +// if (isCompositionPage){ + artifactLabelWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue()); +// } +// else{ +// selectList = GeneralUIUtils.getSelectList("Create New Artifact", DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue()); +// artifactLabelWebElement = GeneralUIUtils.getDriver().findElement(By.name(DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue())); +// } + + artifactLabelWebElement.clear(); + artifactLabelWebElement.sendKeys(requiredArtifactLabel); + return selectList; + } + + public Select selectArtifactType(String artifactType) { + return GeneralUIUtils.getSelectList(artifactType, DataTestIdEnum.ArtifactPopup.ARTIFACT_TYPE.getValue()); + } + + public void clickDoneButton() throws Exception { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPopup.DONE_BUTTON.getValue()); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.waitForElementInVisibilityBy(By.className("sdc-add-artifact"), 10); + } + + public void clickCancelButton() throws Exception { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.CANCEL_BUTTON.getValue()).click(); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.waitForElementInVisibilityByTestId("sdc-add-artifact"); + } + +// public void clickUpdateButton() throws Exception { +// clickAddButton(); +// GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.UPDATE_BUTTON.getValue()).click(); +// GeneralUIUtils.waitForLoader(); +// GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("sdc-add-artifact"), 50); +// } + + public void insertURL(String artifactDescriptoin) throws Exception { + WebElement artifactDescriptionTextbox = getArtifactURLWebElement(); + artifactDescriptionTextbox.clear(); + artifactDescriptionTextbox. sendKeys(artifactDescriptoin); + } + + public WebElement getArtifactURLWebElement(){ + return GeneralUIUtils.getWebElementBy(By.cssSelector((DataTestIdEnum.ArtifactPopup.URL.getValue()))); + } + + +} |