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