re base code
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / pages / PropertiesPage.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.pages;
22
23 import com.aventstack.extentreports.Status;
24 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
25 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
26 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
27 import org.openqa.selenium.By;
28 import org.openqa.selenium.WebElement;
29
30 import java.util.List;
31
32 public class PropertiesPage extends GeneralPageElements {
33
34         public PropertiesPage() {
35                 super();
36         }
37
38         public static List<WebElement> getElemenetsFromTable() {
39                 return GeneralUIUtils.getInputElements(DataTestIdEnum.PropertiesPageEnum.PROPERTY_ROW.getValue());
40         }
41
42         public static void clickAddPropertyArtifact() {
43                 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.ADD_NEW_PROPERTY.getValue()).click();
44                 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue());
45         }
46
47         public static void clickEditPropertyArtifact(String propertyName) {
48                 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.EDIT_PROPERTY.getValue() + propertyName).click();
49         }
50
51         public static void clickDeletePropertyArtifact(String propertyName) {
52                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Delete property %s", propertyName));
53                 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propertyName);
54                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPageEnum.DELETE_PROPERTY.getValue() + propertyName);
55                 GeneralPageElements.clickOKButton();
56                 GeneralUIUtils.waitForElementInVisibilityBy(By.className("w-sdc-modal-confirmation"), 10);
57         }
58
59         public static void clickDeletePropertyFromPopup(String propertyName) {
60                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Delete property %s", propertyName));
61                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propertyName);
62                 GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.PropertiesPageEnum.DELETE_PROPERTY_POPUP.getValue());
63                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue());
64         }
65
66         public static void clickOnProperty(String propertyName) {
67                 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propertyName).click();
68         }
69
70         public static PropertyPopup getPropertyPopup() {
71                 return new PropertyPopup();
72         }
73         
74         public static boolean verifyTotalProperitesField(int count){
75                 String totalPropertiesCount = GeneralUIUtils.getWebElementBy(By.id("properties-count")).getText();
76                 return ("Total Properties: " + count).equals(totalPropertiesCount);
77         }
78         
79
80 }