2 * ============LICENSE_START=======================================================
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
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;
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;
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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());
116 searchTextbox.clear();
117 searchTextbox.sendKeys(resourceName);
118 GeneralUIUtils.ultimateWait();
121 SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");
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());
132 SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName);
137 public static void clickOnProperty(String propertyName)throws Exception {
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());
145 public static void clickOnAddValueToList(String propertyName)throws Exception {
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());
153 SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on Add To List button of component named " + propertyName);
158 public static void clickODeleteValueFromList(String propertyName, int index)throws Exception {
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());
166 SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on Delete From List button of component named " + propertyName);
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();
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();
183 public static void clickOnComponentInComposition(String resourceName) throws Exception{
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());
191 SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName);
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;
201 searchTextbox.clear();
202 searchTextbox.sendKeys(searchPattern);
203 GeneralUIUtils.ultimateWait();
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());
210 searchTextbox.clear();
211 searchTextbox.sendKeys(resourceName);
212 GeneralUIUtils.ultimateWait();
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);
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();
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);
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();
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);
252 public static boolean isButtonDisabled(String dataTestId){
253 return GeneralUIUtils.checkForDisabledAttribute(dataTestId);
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;
260 actualPropertyValue = GeneralUIUtils.getSelectedElementFromDropDown(propertyName).getText();
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);
267 GeneralUIUtils.getSelectList(propertyValue, propertyName);
269 catch(NoSuchElementException e){}
270 return actualPropertyValue;
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();
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();
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();
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();
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();
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();
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();
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();
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());
328 searchTextbox.clear();
329 searchTextbox.sendKeys(resourceName);
330 GeneralUIUtils.ultimateWait();
333 SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");