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