2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.pages;
23 import java.util.List;
25 import org.openecomp.sdc.ci.tests.datatypes.CanvasElement;
26 import org.openecomp.sdc.ci.tests.datatypes.CanvasManager;
27 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
28 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems;
29 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
30 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
31 import org.openqa.selenium.By;
32 import org.openqa.selenium.WebElement;
33 import org.openqa.selenium.interactions.Actions;
34 import org.openqa.selenium.support.ui.Select;
36 import com.aventstack.extentreports.Status;
38 public class CompositionPage extends GeneralPageElements {
40 public CompositionPage() {
44 public static UploadArtifactPopup artifactPopup() {
45 return new UploadArtifactPopup(true);
48 public static void searchForElement(String elementName) {
49 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + elementName + " in the left panel");
50 WebElement searchField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.SEARCH_ASSET.getValue());
52 searchField.sendKeys(elementName);
53 GeneralUIUtils.ultimateWait();
56 public static void showDeploymentArtifactTab() throws Exception {
57 clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB);
60 public static void showInformationsTab() throws Exception {
61 clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.INFORMATION_TAB);
64 public static void showPropertiesAndAttributesTab() throws Exception {
65 clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.PROPERTIES_AND_ATTRIBUTES_TAB);
68 public static List<WebElement> getProperties() {
69 return PropertiesPage.getElemenetsFromTable();
72 public static List<WebElement> getDeploymentArtifacts() {
73 return getAllAddedArtifacts();
76 public static List<WebElement> getAllAddedArtifacts() {
77 String dataTestsId = DataTestIdEnum.CompositionScreenEnum.ARTIFACTS_LIST.getValue();
78 return GeneralUIUtils.getWebElementsListBy(By.xpath("//*[contains(@data-tests-id,'" + dataTestsId + "')]"));
81 public static void moveToInputsScreen() throws Exception {
83 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.MENU_INPUTS.getValue());
84 GeneralUIUtils.ultimateWait();
87 private static void OpenPagesMenu() {
88 Actions actions = new Actions(GeneralUIUtils.getDriver());
89 List<WebElement> triangleList = GeneralUIUtils.getWebElementsListByClassName(DataTestIdEnum.CompositionScreenEnum.MENU_TRIANGLE_DROPDOWN.getValue());
90 WebElement pagesMenu = triangleList.get(2);
91 actions.moveToElement(pagesMenu).perform();
94 public static void changeComponentVersion(CanvasManager canvasManager, CanvasElement element, String version) {
96 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Changing component version to %s", version));
97 canvasManager.clickOnCanvaElement(element);
98 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue());
99 GeneralUIUtils.ultimateWait();
100 Select selectlist = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue()));
101 while (selectlist.getOptions().size() == 0) {
102 selectlist = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue()));
104 GeneralUIUtils.ultimateWait();;
105 selectlist.selectByValue(version);
106 GeneralUIUtils.ultimateWait();
107 GeneralUIUtils.clickSomewhereOnPage();
114 public static void clickAddArtifactButton() throws Exception{
115 clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.ADD_ARTIFACT);
116 GeneralUIUtils.getWebElementByClassName("sdc-add-artifact");
119 public static String getSelectedInstanceName(){
120 return GeneralUIUtils.getWebElementByTestID("selectedCompTitle").getText();
123 public static void showInformationArtifactTab() throws Exception {
124 clickOnTab(DataTestIdEnum.CompositionScreenEnum.INFORMATION_ARTIFACTS);
127 public static void showAPIArtifactTab() throws Exception {
128 clickOnTab(DataTestIdEnum.CompositionScreenEnum.API);
131 public static void showInformationTab() throws Exception {
132 clickOnTab(DataTestIdEnum.CompositionScreenEnum.INFORMATION);
135 public static void showCompositionTab() throws Exception {
136 clickOnTab(DataTestIdEnum.CompositionScreenEnum.COMPOSITION);
139 public static void showInputsTab() throws Exception {
140 clickOnTab(DataTestIdEnum.CompositionScreenEnum.INPUTS);
143 public static void showRequirementsAndCapabilitiesTab() throws Exception {
144 clickOnTab(DataTestIdEnum.CompositionScreenEnum.REQUIREMENTS_AND_CAPABILITIES);
147 public static List<WebElement> getOpenTabTitle() throws Exception{
148 // return GeneralUIUtils.getElementsByCSS("expand-collapse span");
149 return GeneralUIUtils.getElementsByCSS("expand-collapse");
152 public static void clickOnTab(DataTestIdEnum.CompositionScreenEnum tabSelector) throws Exception{
153 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", tabSelector.name()));
154 GeneralUIUtils.getElementsByCSS(tabSelector.getValue()).get(0).click();
155 GeneralUIUtils.ultimateWait();
158 public static void clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum tabSelector) throws Exception{
159 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", tabSelector.name()));
160 GeneralUIUtils.getWebElementByTestID(tabSelector.getValue()).click();
161 GeneralUIUtils.ultimateWait();
164 public static CanvasElement addElementToCanvasScreen(LeftPanelCanvasItems elementName, CanvasManager vfCanvasManager) throws Exception{
165 CompositionPage.searchForElement(elementName.name());
166 return vfCanvasManager.createElementOnCanvas(elementName);
169 public static CanvasElement addElementToCanvasScreen(String elementName, CanvasManager vfCanvasManager) throws Exception{
170 CompositionPage.searchForElement(elementName);
171 return vfCanvasManager.createElementOnCanvas(elementName);
174 public static List<WebElement> getCompositionDeplymentArtifacts() {
175 return GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue());
177 public static WebElement getCustomizationUUID() throws Exception {
178 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CUSTOMIZATION_UUID.getValue());
182 public static List<WebElement> getCompositionEnvArtifacts(){
183 return GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ENV.getValue());
186 public static WebElement clickDownloadEnvArtifactComposition(String fileName) {
187 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ENV.getValue() + fileName);
188 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue() +fileName);