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.ArrayList;
25 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
27 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
28 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
29 import org.openqa.selenium.By;
30 import org.openqa.selenium.WebElement;
32 import com.aventstack.extentreports.Status;
39 public class ProductGeneralPage extends ResourceGeneralPage {
41 public ProductGeneralPage() {
45 public static ProductLeftMenu getProductLeftMenu() {
46 return new ProductLeftMenu();
49 public static void defineName(String productName) {
50 WebElement productNameTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PRODUCT_NAME.getValue());
51 productNameTextbox.clear();
52 productNameTextbox.sendKeys(productName);
55 public static void defineFullName(String productFullName) {
56 WebElement productFullNameTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.FULL_NAME.getValue());
57 productFullNameTextbox.clear();
58 productFullNameTextbox.sendKeys(productFullName);
61 public static void defineProjectCode(String pmat) {
62 WebElement pmattTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PROJECT_CODE.getValue());
64 pmattTextbox.sendKeys(pmat);
67 public static String getPmattText(){
68 return getPmattField().getAttribute("value");
71 public static String[] getTags(){
72 return ResourceGeneralPage.getElementsFromTagsTable().stream().map(WebElement::getText).toArray(String[]::new);
75 private static WebElement getPmattField() {
76 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PROJECT_CODE.getValue());
79 public static void deleteOldTags(ProductReqDetails product){
80 // Delete tag elements
81 int i = GeneralUIUtils.getWebElementsListByTestID("i-sdc-tag-delete").size();
83 GeneralUIUtils.getWebElementByTestID("i-sdc-tag-delete").click();
87 product.setTags(new ArrayList<String>());
90 public static void clickAddWorkflow (){
91 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding workflow..."));
92 GeneralUIUtils.clickOnElementByText("Add Workflow");
95 public static void fillAndAddNewWorkflow(String name, String description ) throws InterruptedException{
96 GeneralUIUtils.ultimateWait();
97 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling name field with %s", name));
98 insertText(name, "label + input");
99 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling description filed with %s", name));
100 insertText(description,"label + textarea");
101 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking save button "));
105 public static void insertText(String artifactDescriptoin, String element) throws InterruptedException {
106 GeneralUIUtils.getElementsByCSS("div[class='modal-content']");
107 WebElement artifactDescriptionTextbox = GeneralUIUtils.getWebElementBy(By.cssSelector(element));
108 artifactDescriptionTextbox.clear();
109 artifactDescriptionTextbox.sendKeys(artifactDescriptoin);
110 GeneralUIUtils.ultimateWait();
113 public static void clickSave() {
114 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save button"));
115 GeneralUIUtils.clickOnElementByText("Save");
116 GeneralUIUtils.ultimateWait();