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.ServiceReqDetails;
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;
34 public class ServiceGeneralPage extends ResourceGeneralPage {
36 public ServiceGeneralPage() {
40 public static ServiceLeftMenu getServiceLeftMenu() {
41 return new ServiceLeftMenu();
44 public static void defineName(String serviceName) {
45 WebElement serviceNameTextbox = GeneralUIUtils
46 .getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.SERVICE_NAME.getValue());
47 serviceNameTextbox.clear();
48 serviceNameTextbox.sendKeys(serviceName);
51 public static void defineProjectCode(String pmat) {
52 WebElement projectCodeTextbox = GeneralUIUtils
53 .getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.PROJECT_CODE.getValue());
54 projectCodeTextbox.clear();
55 projectCodeTextbox.sendKeys(pmat);
58 public static String getProjectCodeText(){
59 return getProjectCodeField().getAttribute("value");
62 public static String[] getTags(){
63 return ResourceGeneralPage.getElementsFromTagsTable().stream().map(WebElement::getText).toArray(String[]::new);
66 private static WebElement getProjectCodeField() {
67 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.PROJECT_CODE.getValue());
70 public static void deleteOldTags(ServiceReqDetails service){
71 // Delete tag elements
72 int i = GeneralUIUtils.getWebElementsListByTestID("i-sdc-tag-delete").size();
74 GeneralUIUtils.getWebElementByTestID("i-sdc-tag-delete").click();
78 service.setTags(new ArrayList<String>());
81 public static String getCategoryText() {
82 return GeneralUIUtils.getSelectedElementFromDropDown(getCategoryDataTestsIdAttribute()).getText();
85 public static void clickAddWorkflow (){
86 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding workflow..."));
87 GeneralUIUtils.clickOnElementByText("Add Workflow");
90 public static void fillAndAddNewWorkflow(String name, String description ) throws InterruptedException{
91 GeneralUIUtils.ultimateWait();
92 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling name field with %s", name));
93 insertText(name, "label + input");
94 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling description filed with %s", name));
95 insertText(description,"label + textarea");
96 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking save button "));
100 public static void insertText(String artifactDescriptoin, String element) throws InterruptedException {
101 GeneralUIUtils.getElementsByCSS("div[class='modal-content']");
102 WebElement artifactDescriptionTextbox = GeneralUIUtils.getWebElementBy(By.cssSelector(element));
103 artifactDescriptionTextbox.clear();
104 artifactDescriptionTextbox.sendKeys(artifactDescriptoin);
105 GeneralUIUtils.ultimateWait();
108 public static void clickSave() {
109 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save button"));
110 GeneralUIUtils.clickOnElementByText("Save");
111 GeneralUIUtils.ultimateWait();