Sync Integ to Master
[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 java.util.List;
5
6 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
7 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.PropertiesAssignmentScreen;
8 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
9 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
10 import org.openqa.selenium.WebElement;
11
12 import com.aventstack.extentreports.Status;
13
14 public class PropertiesAssignmentPage {
15         public static void clickOnInputTab(){
16                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Input Tab"));
17                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUTS_TAB.getValue());
18                 GeneralUIUtils.ultimateWait();          
19         }
20         
21         public static void clickOnPropertiesTab(){
22                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Properties Tab"));
23                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTIES_TAB.getValue());
24                 GeneralUIUtils.ultimateWait();          
25         }
26         
27         public static void clickOnCompositionRightTab(){
28                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Composition Right Tab"));
29                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.COMPOSITION_TAB.getValue());
30                 GeneralUIUtils.ultimateWait();          
31         }
32         
33         public static void clickOnPropertyStructureRightTab(){
34                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Property Structure Right Tab"));
35                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTY_STRUCTURE_TAB.getValue());
36                 GeneralUIUtils.ultimateWait();          
37         }
38         
39         public static void clickOnDeclareButton(){
40                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Declare Button"));
41                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DECLARE_BUTTON.getValue());
42                 GeneralUIUtils.ultimateWait();          
43         }
44         
45         public static void findSearchBoxAndClick(String resourceName) throws Exception {
46                 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " in Properties");
47                 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
48                 try{
49                         searchTextbox.clear();
50                         searchTextbox.sendKeys(resourceName);
51                         GeneralUIUtils.ultimateWait();
52                 }
53                 catch(Exception e){
54                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");
55                         e.printStackTrace();
56                 }
57                 
58                 
59                 try{
60                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component in Properties", resourceName));
61                         GeneralUIUtils.clickOnElementByTestId(resourceName);
62                         GeneralUIUtils.ultimateWait();
63                         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
64                 }
65                 catch(Exception e){
66                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName);
67                         e.printStackTrace();
68                 }
69         }
70         
71         public static void clickOnProperty(String propertyName) {
72                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on property %s ", propertyName));
73                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_NAME.getValue() + propertyName);
74                 GeneralUIUtils.ultimateWait();
75         }
76         
77         public static void clickOnDeleteInputButton(){
78                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Delete Input Button"));
79                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_BUTTON.getValue());
80                 GeneralUIUtils.ultimateWait();          
81         }
82         
83         public static void clickOnDeleteInputDialogConfirmationButton(){
84                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Delete Input Dialog Confirmation Button"));
85                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_DELETE.getValue());
86                 GeneralUIUtils.ultimateWait();          
87         }
88         
89         
90         
91         public static void clickOnComponentInComposition(String resourceName) throws Exception{
92                 try{
93                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component on Properties screen", resourceName));
94                         GeneralUIUtils.clickOnElementByTestId(resourceName);
95                         GeneralUIUtils.ultimateWait();
96                         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
97                 }
98                 catch(Exception e){
99                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName);
100                         e.printStackTrace();
101                 }
102         }
103         
104         public static void findInput(String componentName, String resourceName) throws Exception {
105                 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + componentName + "_" + resourceName + " on Inputs screen");
106                 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
107                 String searchPattern = componentName + "_" + resourceName;
108                 try{
109                         searchTextbox.clear();
110                         searchTextbox.sendKeys(searchPattern);
111                         GeneralUIUtils.ultimateWait();
112                 }
113                 catch(Exception e){
114                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");
115                         e.printStackTrace();
116                 }
117                 
118         }
119         
120         public static void findProperty(String resourceName) throws Exception {
121                 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen");
122                 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
123                 
124                 try{
125                         searchTextbox.clear();
126                         searchTextbox.sendKeys(resourceName);
127                         GeneralUIUtils.ultimateWait();
128                 }
129                 catch(Exception e){
130                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");
131                         e.printStackTrace();
132                 }
133                 
134         }
135         
136         public static Boolean isPropertyChecked(String resourceName){
137 //              TODO add better implementation for css string
138                 GeneralUIUtils.ultimateWait();
139                 Boolean isDisabled = GeneralUIUtils.checkForDisabledAttributeInHiddenElement("checkbox[data-tests-id='" + resourceName + "'] input");
140                 if (isDisabled)
141                         return true;
142                 return false;
143                 
144         }
145         
146         
147         //Filter Actions
148                 public static void clickOnFilterButton() {
149                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter button "));
150                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_BUTTON.getValue());
151                         GeneralUIUtils.ultimateWait();
152                 }
153                 
154                 public static void clickOnFilterAllCheckbox() {
155                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter All Checkbox "));
156                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_ALL.getValue());
157                         GeneralUIUtils.ultimateWait();
158                 }
159                 
160                 public static void clickOnFilterCPCheckbox() {
161                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter CP Checkbox "));
162                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_CP.getValue());
163                         GeneralUIUtils.ultimateWait();
164                 }
165                 
166                 public static void clickOnFilterVfcCheckbox() {
167                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter VFC Checkbox "));
168                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_VFC.getValue());
169                         GeneralUIUtils.ultimateWait();
170                 }
171                 
172                 public static void clickOnFilterVlCheckbox() {
173                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter VL Checkbox "));
174                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_VL.getValue());
175                         GeneralUIUtils.ultimateWait();
176                 }
177                 
178                 public static void clickOnFilterApplyButton(){
179                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Apply Button"));
180                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_APPLY_BUTTON.getValue());
181                         GeneralUIUtils.ultimateWait();          
182                 }
183                 
184                 public static void clickOnFilterCloseButton(){
185                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Close Button"));
186                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CLOSE_BUTTON.getValue());
187                         GeneralUIUtils.ultimateWait();          
188                 }
189                 
190                 public static void clickOnFilterClearAllButton(){
191                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Clear All Button"));
192                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.CLEAR_FILTER_BUTTON.getValue());
193                         GeneralUIUtils.ultimateWait();          
194                 }
195                 
196                 public static void findFilterBoxAndClick(String resourceName) throws Exception {
197                         SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property in Properties table");
198                         WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.FILTER_BOX.getValue());
199                         try{
200                                 searchTextbox.clear();
201                                 searchTextbox.sendKeys(resourceName);
202                                 GeneralUIUtils.ultimateWait();
203                         }
204                         catch(Exception e){
205                                 SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");
206                                 e.printStackTrace();
207                         }
208
209                 }
210         
211         
212 }