2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.onap.sdc.frontend.ci.tests.pages;
23 import com.aventstack.extentreports.Status;
24 import org.onap.sdc.frontend.ci.tests.datatypes.DataTestIdEnum;
25 import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest;
26 import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils;
27 import org.openqa.selenium.By;
28 import org.openqa.selenium.NoSuchElementException;
29 import org.openqa.selenium.WebElement;
30 import org.openqa.selenium.support.ui.Select;
32 public class PropertyPopup {
35 private static final int WAIT_FOR_ELEMENT_TIME_OUT = 60;
37 private boolean getPopupForm() {
38 return GeneralUIUtils.waitForElementInVisibilityByTestId(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue(), WAIT_FOR_ELEMENT_TIME_OUT);
41 public void insertPropertyName(String name) {
42 WebElement propertyNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_NAME.getValue());
43 propertyNameField.clear();
44 propertyNameField.sendKeys(name);
47 public void insertPropertyDefaultValue(String value) {
48 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Inserting to property default value: %s ", value));
49 WebElement selectedType = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue())).getFirstSelectedOption();
50 if (selectedType.getText().equals("boolean")) {
51 GeneralUIUtils.getSelectList(value, DataTestIdEnum.PropertiesPopupEnum.PROPERTY_BOOLEAN_VALUE.getValue());
53 WebElement propertyValue = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_VALUE.getValue());
54 propertyValue.clear();
55 propertyValue.sendKeys(value);
58 GeneralUIUtils.ultimateWait();
61 public void insertPropertyDescription(String description) {
62 WebElement propertyDescription = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_DESCRIPTION.getValue());
63 propertyDescription.clear();
64 propertyDescription.sendKeys(description);
67 public void selectPropertyType(String propertyType) {
68 boolean isEntrySchemaDisplayed;
70 GeneralUIUtils.getSelectList(propertyType, DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue());
71 isEntrySchemaDisplayed = GeneralUIUtils.getDriver().findElement(By.xpath(DataTestIdEnum.PropertiesPopupEnum.ENTRY_SCHEMA.getValue())).isDisplayed();
72 if (isEntrySchemaDisplayed) {
73 PropertiesPage.getPropertyPopup().selectEntrySchema(propertyType);
75 } catch (NoSuchElementException e) {
80 public void selectEntrySchema(String propertyType) {
81 GeneralUIUtils.getSelectList(propertyType, DataTestIdEnum.PropertiesPopupEnum.ENTRY_SCHEMA.getValue());
84 public void clickAdd() {
85 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.ADD.getValue());
86 //GeneralUIUtils.ultimateWait();
89 public void clickSave() {
90 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.SAVE.getValue());
94 public void clickCancel() {
95 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.CANCEL.getValue());
96 //GeneralUIUtils.ultimateWait();
99 public void clickDone() {
100 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.DONE.getValue());
101 //GeneralUIUtils.ultimateWait();
104 public void selectPropertyRadioButton(String propertyName) {
105 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_RADIO_BUTTON_CONTAINER.getValue() + propertyName).findElement(By.className(DataTestIdEnum.PropertiesPopupEnum.RADIO_BUTTON_CLASS.getValue())).click();