Final commit to master merge from
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / pages / PropertiesAssignmentPage.java
1 package org.openecomp.sdc.ci.tests.pages;
2
3
4 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
5 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.PropertiesAssignmentScreen;
6 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
7 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
8 import org.openqa.selenium.WebElement;
9
10 import com.aventstack.extentreports.Status;
11
12 public class PropertiesAssignmentPage {
13         public static void clickOnInputTab(){
14                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Input Tab"));
15                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUTS_TAB.getValue());
16                 GeneralUIUtils.ultimateWait();          
17         }
18         
19         public static void clickOnPropertiesTab(){
20                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Properties Tab"));
21                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTIES_TAB.getValue());
22                 GeneralUIUtils.ultimateWait();          
23         }
24         
25         public static void clickOnCompositionRightTab(){
26                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Composition Right Tab"));
27                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.COMPOSITION_TAB.getValue());
28                 GeneralUIUtils.ultimateWait();          
29         }
30         
31         public static void clickOnPropertyStructureRightTab(){
32                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Property Structure Right Tab"));
33                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTY_STRUCTURE_TAB.getValue());
34                 GeneralUIUtils.ultimateWait();          
35         }
36         
37         public static void clickOnDeclareButton(){
38                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Declare Button"));
39                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DECLARE_BUTTON.getValue());
40                 GeneralUIUtils.ultimateWait();          
41         }
42         
43         public static void findSearchBoxAndClick(String resourceName) throws Exception {
44                 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " in homepage");
45                 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
46                 try{
47                         searchTextbox.clear();
48                         searchTextbox.sendKeys(resourceName);
49                         GeneralUIUtils.ultimateWait();
50                 }
51                 catch(Exception e){
52                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");
53                         e.printStackTrace();
54                 }
55                 
56                 
57                 try{
58                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component from home screen", resourceName));
59                         GeneralUIUtils.clickOnElementByTestId(resourceName);
60                         GeneralUIUtils.ultimateWait();
61                         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
62                 }
63                 catch(Exception e){
64                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName);
65                         e.printStackTrace();
66                 }
67         }
68         
69         public static void clickOnProperty(String propertyName) {
70                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on property %s ", propertyName));
71                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_NAME.getValue() + propertyName);
72                 GeneralUIUtils.ultimateWait();
73         }
74         
75         public static void clickOnDeleteInputButton(){
76                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Delete Input Button"));
77                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_BUTTON.getValue());
78                 GeneralUIUtils.ultimateWait();          
79         }
80         
81         public static void clickOnDeleteInputDialogConfirmationButton(){
82                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Delete Input Dialog Confirmation Button"));
83                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_DELETE.getValue());
84                 GeneralUIUtils.ultimateWait();          
85         }
86         
87         public static void clickOnFilterAll() {
88                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on property %s "));
89                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_ALL.getValue());
90                 GeneralUIUtils.ultimateWait();
91         }
92         
93         public static void clickOnComponentInComposition(String resourceName) throws Exception{
94                 try{
95                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component from properties composition", resourceName));
96                         GeneralUIUtils.clickOnElementByTestId(resourceName);
97                         GeneralUIUtils.ultimateWait();
98                         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
99                 }
100                 catch(Exception e){
101                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName);
102                         e.printStackTrace();
103                 }
104         }
105         
106         public static void findInput(String componentName, String resourceName) throws Exception {
107                 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + componentName + "_" + resourceName + " in homepage");
108                 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
109                 String searchPattern = componentName + "_" + resourceName;
110                 try{
111                         searchTextbox.clear();
112                         searchTextbox.sendKeys(searchPattern);
113                         GeneralUIUtils.ultimateWait();
114                 }
115                 catch(Exception e){
116                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");
117                         e.printStackTrace();
118                 }
119                 
120         }
121         
122         public static void findProperty(String resourceName) throws Exception {
123                 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " in homepage");
124                 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
125                 
126                 try{
127                         searchTextbox.clear();
128                         searchTextbox.sendKeys(resourceName);
129                         GeneralUIUtils.ultimateWait();
130                 }
131                 catch(Exception e){
132                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");
133                         e.printStackTrace();
134                 }
135                 
136         }
137         
138         public static Boolean isPropertyChecked(String resourceName){
139 //              TODO add better implementation for css string
140                 GeneralUIUtils.ultimateWait();
141                 Boolean isDisabled = GeneralUIUtils.checkForDisabledAttributeInHiddenElement("checkbox[data-tests-id='" + resourceName + "'] input");
142                 if (isDisabled)
143                         return true;
144                 return false;
145                 
146         }
147         
148         
149 }