Added oparent to sdc main
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / pages / PropertiesAssignmentPage.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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
24 import com.aventstack.extentreports.Status;
25 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.PropertiesAssignmentScreen;
27 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
28 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
29 import org.openqa.selenium.Keys;
30 import org.openqa.selenium.NoSuchElementException;
31 import org.openqa.selenium.WebElement;
32
33 public class PropertiesAssignmentPage {
34         public static void clickOnInputTab(){
35                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Input Tab"));
36                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUTS_TAB.getValue());
37 //              GeneralUIUtils.ultimateWait();
38         }
39         
40         public static void clickOnPropertiesTab(){
41                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Properties Tab"));
42                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTIES_TAB.getValue());
43 //              GeneralUIUtils.ultimateWait();
44         }
45         
46         public static void clickOnCompositionRightTab(){
47                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Composition Right Tab"));
48                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.COMPOSITION_TAB.getValue());
49 //              GeneralUIUtils.ultimateWait();
50         }
51         
52         public static void clickOnPropertyStructureRightTab(){
53                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Property Structure Right Tab"));
54                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTY_STRUCTURE_TAB.getValue());
55 //              GeneralUIUtils.ultimateWait();
56         }
57         
58         public static void clickOnDeclareButton(){
59                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Declare Button"));
60                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DECLARE_BUTTON.getValue());
61 //              GeneralUIUtils.ultimateWait();
62         }
63
64         public static void clickOnSaveButton(){
65                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save Button"));
66                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_BUTTON.getValue());
67 //              GeneralUIUtils.ultimateWait();
68         }
69
70         public static void clickOnDiscardButton(){
71                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Discard Button"));
72                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DISCARD_BUTTON.getValue());
73 //              GeneralUIUtils.ultimateWait();
74         }
75
76         public static void clickOnDialogSaveButton(){
77                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save Button in Dialog Popup"));
78                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_DIALOG_SAVE.getValue());
79 //              GeneralUIUtils.ultimateWait();
80         }
81
82         public static void clickOnDialogDiscardButton(){
83                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Discard Button in Dialog Popup"));
84                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_DIALOG_DISCARD.getValue());
85 //              GeneralUIUtils.ultimateWait();
86         }
87
88         public static void clickOnDialogCancelButton(){
89         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Cancel Button in Dialog Popup"));
90         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_DIALOG_CANCEL.getValue());
91 //        GeneralUIUtils.ultimateWait();
92     }
93
94         public static void clickOnEditButton(String propertyName) {
95                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Edit button "));
96                 GeneralUIUtils.clickOnElementByTestId(PropertyNameBuilder.buildPopupField(propertyName));
97 //              GeneralUIUtils.ultimateWait();
98         }
99
100     public static void clickOnSetButton() {
101         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Set button in a property popup "));
102         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_SET_BUTTON.getValue());
103 //        GeneralUIUtils.ultimateWait();
104     }
105
106     public static void clickOnExpandButton(String propertyName, int index){
107         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Expand Complex Property Button"));
108         GeneralUIUtils.clickOnElementByTestId(PropertyNameBuilder.buildIExpandButton(propertyName, index));
109 //        GeneralUIUtils.ultimateWait();
110     }
111         
112         public static void findSearchBoxAndClick(String resourceName) throws Exception {
113                 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " in Properties");
114                 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
115                 try{
116                         searchTextbox.clear();
117                         searchTextbox.sendKeys(resourceName);
118                         GeneralUIUtils.ultimateWait();
119                 }
120                 catch(Exception e){
121                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");
122                         e.printStackTrace();
123                 }
124
125                 try{
126                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component in Properties", resourceName));
127                         GeneralUIUtils.clickOnElementByInputTestIdWithoutWait(resourceName);
128                         GeneralUIUtils.ultimateWait();
129                         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
130                 }
131                 catch(Exception e){
132                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName);
133                         e.printStackTrace();
134                 }
135         }
136         
137         public static void clickOnProperty(String propertyName)throws Exception {
138
139                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component in Properties", propertyName));
140                         GeneralUIUtils.clickOnElementByTestId(propertyName);
141 //                      GeneralUIUtils.ultimateWait();
142                         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
143         }
144
145         public static void clickOnAddValueToList(String propertyName)throws Exception {
146                 try{
147                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the Add To List button of %s component in Properties", propertyName));
148                         GeneralUIUtils.clickOnElementByTestId( PropertiesAssignmentScreen.ADD_TO_LIST_BUTTON.getValue() + propertyName);
149 //                      GeneralUIUtils.ultimateWait();
150                         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
151                 }
152                 catch(Exception e){
153                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on Add To List button of component named " + propertyName);
154                         e.printStackTrace();
155                 }
156         }
157
158     public static void clickODeleteValueFromList(String propertyName, int index)throws Exception {
159         try{
160             SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the Delete From List button of %s component in Properties", propertyName));
161             GeneralUIUtils.clickOnElementByTestId( PropertiesAssignmentScreen.DELETE_FROM_LIST_BUTTON.getValue() + propertyName + "." + String.valueOf(index));
162 //            GeneralUIUtils.ultimateWait();
163             GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
164         }
165         catch(Exception e){
166             SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on Delete From List button of component named " + propertyName);
167             e.printStackTrace();
168         }
169     }
170         
171         public static void clickOnDeleteInputButton(){
172                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Delete Input Button"));
173                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_BUTTON.getValue());
174 //              GeneralUIUtils.ultimateWait();
175         }
176         
177         public static void clickOnDeleteInputDialogConfirmationButton(){
178                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Delete Input Dialog Confirmation Button"));
179                 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_DELETE.getValue());
180 //              GeneralUIUtils.ultimateWait();
181         }
182
183         public static void clickOnComponentInComposition(String resourceName) throws Exception{
184                 try{
185                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component on Properties screen", resourceName));
186                         GeneralUIUtils.clickOnElementByTestId(resourceName);
187 //                      GeneralUIUtils.ultimateWait();
188 //                      GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
189                 }
190                 catch(Exception e){
191                         SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName);
192                         e.printStackTrace();
193                 }
194         }
195         
196         public static void findInput(String componentName, String resourceName) throws Exception {
197                 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + componentName + "_" + resourceName + " on Inputs screen");
198                 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
199                 String searchPattern = componentName + "_" + resourceName;
200
201                 searchTextbox.clear();
202                 searchTextbox.sendKeys(searchPattern);
203                 GeneralUIUtils.ultimateWait();
204         }
205         
206         public static void findProperty(String resourceName) throws Exception {
207                 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen");
208                 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
209
210                 searchTextbox.clear();
211                 searchTextbox.sendKeys(resourceName);
212                 GeneralUIUtils.ultimateWait();
213         }
214
215         public static void editPropertyValue(String resourceName, String value) throws Exception {
216                 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen");
217                 WebElement valueTextbox = GeneralUIUtils.getWebElementByTestID(resourceName);
218
219         clickOnProperty(resourceName);
220                 valueTextbox.clear();
221                 SetupCDTest.getExtendTest().log(Status.INFO, "Editing " + resourceName + " property on Properties screen");
222                 valueTextbox.sendKeys(value);
223                 GeneralUIUtils.ultimateWait();
224
225         }
226
227     public static void deletePropertyValue(String resourceName) throws Exception {
228         SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen");
229         WebElement valueTextbox = GeneralUIUtils.getWebElementByTestID(resourceName);
230
231         clickOnProperty(resourceName);
232         SetupCDTest.getExtendTest().log(Status.INFO, "Deleting " + resourceName + " property on Properties screen");
233         valueTextbox.sendKeys(Keys.chord(Keys.CONTROL, "a"));
234         valueTextbox.sendKeys(Keys.BACK_SPACE);
235         GeneralUIUtils.ultimateWait();
236
237     }
238
239
240         public static Boolean isPropertyChecked(String resourceName){
241 //              TODO add better implementation for css string
242                 GeneralUIUtils.ultimateWait();
243                 Boolean isDisabled = GeneralUIUtils.checkForDisabledAttributeInHiddenElement("checkbox[data-tests-id='" + resourceName + "'] input");
244                 SetupCDTest.getExtendTest().log(Status.INFO, "Is property checkbox disabled? " +  isDisabled);
245                 if (isDisabled)
246                         return true;
247                 return false;
248
249                 
250         }
251
252         public static boolean isButtonDisabled(String dataTestId){
253                 return GeneralUIUtils.checkForDisabledAttribute(dataTestId);
254         }
255
256         public static String selectBooleanPropertyValue(String propertyName, String propertyValue) {
257         SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + propertyName + " property on Properties screen");
258                 String actualPropertyValue = null;
259                 try{
260                         actualPropertyValue = GeneralUIUtils.getSelectedElementFromDropDown(propertyName).getText();
261                 }
262                 catch(NoSuchElementException e){
263                         SetupCDTest.getExtendTest().log(Status.INFO, "#selectBooleanPropertyValue - Failed to get selected boolean property value ");
264                         SetupCDTest.getExtendTest().log(Status.INFO, e);
265                 }
266         try{
267                         GeneralUIUtils.getSelectList(propertyValue, propertyName);
268                 }
269                 catch(NoSuchElementException e){}
270                 return actualPropertyValue;
271         }
272
273
274         
275         //Filter Actions
276                 public static void clickOnFilterButton() {
277                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter button "));
278                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_BUTTON.getValue());
279 //                      GeneralUIUtils.ultimateWait();
280                 }
281                 
282                 public static void clickOnFilterAllCheckbox() {
283                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter All Checkbox "));
284                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_ALL.getValue());
285 //                      GeneralUIUtils.ultimateWait();
286                 }
287                 
288                 public static void clickOnFilterCPCheckbox() {
289                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter CP Checkbox "));
290                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_CP.getValue());
291 //                      GeneralUIUtils.ultimateWait();
292                 }
293                 
294                 public static void clickOnFilterVfcCheckbox() {
295                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter VFC Checkbox "));
296                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_VFC.getValue());
297 //                      GeneralUIUtils.ultimateWait();
298                 }
299                 
300                 public static void clickOnFilterVlCheckbox() {
301                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter VL Checkbox "));
302                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_VL.getValue());
303 //                      GeneralUIUtils.ultimateWait();
304                 }
305                 
306                 public static void clickOnFilterApplyButton(){
307                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Apply Button"));
308                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_APPLY_BUTTON.getValue());
309 //                      GeneralUIUtils.ultimateWait();
310                 }
311                 
312                 public static void clickOnFilterCloseButton(){
313                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Close Button"));
314                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CLOSE_BUTTON.getValue());
315 //                      GeneralUIUtils.ultimateWait();
316                 }
317                 
318                 public static void clickOnFilterClearAllButton(){
319                         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Clear All Button"));
320                         GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.CLEAR_FILTER_BUTTON.getValue());
321 //                      GeneralUIUtils.ultimateWait();
322                 }
323                 
324                 public static void findFilterBoxAndClick(String resourceName) throws Exception {
325                         SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property in Properties table");
326                         WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.FILTER_BOX.getValue());
327                         try{
328                                 searchTextbox.clear();
329                                 searchTextbox.sendKeys(resourceName);
330                                 GeneralUIUtils.ultimateWait();
331                         }
332                         catch(Exception e){
333                                 SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");
334                                 e.printStackTrace();
335                         }
336
337                 }
338         
339         
340 }