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.exception.PropertiesAssignmentPageException;
28 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
29 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
30 import org.openqa.selenium.Keys;
31 import org.openqa.selenium.NoSuchElementException;
32 import org.openqa.selenium.WebElement;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 public class PropertiesAssignmentPage {
38 private static final Logger LOGGER = LoggerFactory.getLogger(PropertiesAssignmentPage.class);
40 private PropertiesAssignmentPage() {
44 public static void clickOnInputTab() {
45 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Input Tab");
46 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUTS_TAB.getValue());
49 public static void clickOnPropertiesTab() {
50 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Properties Tab");
51 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTIES_TAB.getValue());
54 public static void clickOnCompositionRightTab() {
55 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Composition Right Tab");
56 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.COMPOSITION_TAB.getValue());
59 public static void clickOnPropertyStructureRightTab() {
60 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Property Structure Right Tab");
61 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTY_STRUCTURE_TAB.getValue());
64 public static void clickOnDeclareButton() {
65 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Declare Button");
66 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DECLARE_BUTTON.getValue());
69 public static void clickOnSaveButton() {
70 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Save Button");
71 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_BUTTON.getValue());
74 public static void clickOnDiscardButton() {
75 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Discard Button");
76 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DISCARD_BUTTON.getValue());
79 public static void clickOnDialogSaveButton() {
80 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Save Button in Dialog Popup");
81 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_DIALOG_SAVE.getValue());
84 public static void clickOnDialogDiscardButton() {
85 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Discard Button in Dialog Popup");
86 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_DIALOG_DISCARD.getValue());
89 public static void clickOnDialogCancelButton() {
90 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Cancel Button in Dialog Popup");
91 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_DIALOG_CANCEL.getValue());
94 public static void clickOnEditButton(String propertyName) {
95 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Edit button ");
96 GeneralUIUtils.clickOnElementByTestId(PropertyNameBuilder.buildPopupField(propertyName));
99 public static void clickOnSetButton() {
100 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Set button in a property popup ");
101 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_SET_BUTTON.getValue());
104 public static void clickOnExpandButton(String propertyName, int index) {
105 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Expand Complex Property Button");
106 GeneralUIUtils.clickOnElementByTestId(PropertyNameBuilder.buildIExpandButton(propertyName, index));
109 public static void findSearchBoxAndClick(final String resourceName) throws PropertiesAssignmentPageException {
110 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " in Properties");
112 final WebElement searchTextbox = GeneralUIUtils
113 .getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
114 searchTextbox.clear();
115 searchTextbox.sendKeys(resourceName);
116 GeneralUIUtils.ultimateWait();
117 } catch (final Exception e) {
118 final String errorMsg = String.format("Could not interact with search bar, test id '%s'",
119 PropertiesAssignmentScreen.SEARCH_BOX.getValue());
120 LOGGER.error(errorMsg, e);
121 SetupCDTest.getExtendTest().log(Status.ERROR, errorMsg);
122 throw new PropertiesAssignmentPageException(errorMsg, e);
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 } catch (final Exception e) {
131 final String errorMsg = String.format("Could not click on component named '%s'", resourceName);
132 LOGGER.error(errorMsg, e);
133 SetupCDTest.getExtendTest().log(Status.ERROR, errorMsg);
134 throw new PropertiesAssignmentPageException(errorMsg, e);
138 private static void clickOnProperty(String propertyName) {
139 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component in Properties", propertyName));
140 GeneralUIUtils.clickOnElementByTestId(propertyName);
141 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
144 public static void clickOnAddValueToList(String propertyName) throws Exception {
146 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the Add To List button of %s component in Properties", propertyName));
147 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.ADD_TO_LIST_BUTTON.getValue() + propertyName);
148 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
149 } catch (Exception e) {
150 SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on Add To List button of component named " + propertyName);
155 public static void clickODeleteValueFromList(String propertyName, int index) throws Exception {
157 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the Delete From List button of %s component in Properties", propertyName));
158 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DELETE_FROM_LIST_BUTTON.getValue() + propertyName + "." + index);
159 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
160 } catch (Exception e) {
161 SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on Delete From List button of component named " + propertyName);
166 public static void clickOnDeleteInputButton() {
167 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Delete Input Button");
168 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_BUTTON.getValue());
171 public static void clickOnDeleteInputDialogConfirmationButton() {
172 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Delete Input Dialog Confirmation Button");
173 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_DELETE.getValue());
176 public static void clickOnComponentInComposition(final String resourceName) throws Exception {
177 SetupCDTest.getExtendTest()
178 .log(Status.INFO, String.format("Clicking on the %s component on Properties screen", resourceName));
180 GeneralUIUtils.clickOnElementByTestId(resourceName);
181 } catch (final Exception e) {
182 SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName);
187 public static void findInput(String componentName, String resourceName) throws Exception {
188 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + componentName + "_" + resourceName + " on Inputs screen");
189 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
190 String searchPattern = componentName + "_" + resourceName;
192 searchTextbox.clear();
193 searchTextbox.sendKeys(searchPattern);
194 GeneralUIUtils.ultimateWait();
197 public static void findProperty(String resourceName) throws Exception {
198 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen");
199 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue());
201 searchTextbox.clear();
202 searchTextbox.sendKeys(resourceName);
203 GeneralUIUtils.ultimateWait();
206 public static void editPropertyValue(String resourceName, String value) throws Exception {
207 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen");
208 WebElement valueTextbox = GeneralUIUtils.getWebElementByTestID(resourceName);
210 clickOnProperty(resourceName);
211 valueTextbox.clear();
212 SetupCDTest.getExtendTest().log(Status.INFO, "Editing " + resourceName + " property on Properties screen");
213 valueTextbox.sendKeys(value);
214 GeneralUIUtils.ultimateWait();
218 public static void deletePropertyValue(String resourceName) throws Exception {
219 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen");
220 WebElement valueTextbox = GeneralUIUtils.getWebElementByTestID(resourceName);
222 clickOnProperty(resourceName);
223 SetupCDTest.getExtendTest().log(Status.INFO, "Deleting " + resourceName + " property on Properties screen");
224 valueTextbox.sendKeys(Keys.chord(Keys.CONTROL, "a"));
225 valueTextbox.sendKeys(Keys.BACK_SPACE);
226 GeneralUIUtils.ultimateWait();
231 public static Boolean isPropertyChecked(String resourceName) {
232 // TODO add better implementation for css string
233 GeneralUIUtils.ultimateWait();
234 Boolean isDisabled = GeneralUIUtils.checkForDisabledAttributeInHiddenElement("checkbox[data-tests-id='" + resourceName + "'] input");
235 SetupCDTest.getExtendTest().log(Status.INFO, "Is property checkbox disabled? " + isDisabled);
239 public static boolean isButtonDisabled(String dataTestId) {
240 return GeneralUIUtils.checkForDisabledAttribute(dataTestId);
243 public static String selectBooleanPropertyValue(String propertyName, String propertyValue) {
244 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + propertyName + " property on Properties screen");
245 String actualPropertyValue = null;
247 actualPropertyValue = GeneralUIUtils.getSelectedElementFromDropDown(propertyName).getText();
248 } catch (NoSuchElementException e) {
249 SetupCDTest.getExtendTest().log(Status.INFO, "#selectBooleanPropertyValue - Failed to get selected boolean property value ");
250 SetupCDTest.getExtendTest().log(Status.INFO, e);
253 GeneralUIUtils.getSelectList(propertyValue, propertyName);
254 } catch (NoSuchElementException e) {
257 return actualPropertyValue;
262 public static void clickOnFilterButton() {
263 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Filter button ");
264 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_BUTTON.getValue());
267 public static void clickOnFilterAllCheckbox() {
268 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Filter All Checkbox ");
269 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_ALL.getValue());
272 public static void clickOnFilterCPCheckbox() {
273 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Filter CP Checkbox ");
274 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_CP.getValue());
277 public static void clickOnFilterVfcCheckbox() {
278 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Filter VFC Checkbox ");
279 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_VFC.getValue());
282 public static void clickOnFilterVlCheckbox() {
283 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Filter VL Checkbox ");
284 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_VL.getValue());
287 public static void clickOnFilterApplyButton() {
288 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Filter Apply Button");
289 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_APPLY_BUTTON.getValue());
292 public static void clickOnFilterCloseButton() {
293 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Filter Close Button");
294 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CLOSE_BUTTON.getValue());
297 public static void clickOnFilterClearAllButton() {
298 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Filter Clear All Button");
299 GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.CLEAR_FILTER_BUTTON.getValue());
302 public static void findFilterBoxAndClick(String resourceName) throws Exception {
303 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property in Properties table");
304 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.FILTER_BOX.getValue());
306 searchTextbox.clear();
307 searchTextbox.sendKeys(resourceName);
308 GeneralUIUtils.ultimateWait();
309 } catch (Exception e) {
310 SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");