Provide user to specify the ouput name while declaring the atrributes
[sdc.git] / integration-tests / src / test / java / org / onap / sdc / frontend / ci / tests / pages / PropertyPopup.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
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.onap.sdc.frontend.ci.tests.pages;
22
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;
31
32 public class PropertyPopup {
33
34
35     private static final int WAIT_FOR_ELEMENT_TIME_OUT = 60;
36
37     private boolean getPopupForm() {
38         return GeneralUIUtils.waitForElementInVisibilityByTestId(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue(), WAIT_FOR_ELEMENT_TIME_OUT);
39     }
40
41     public void insertPropertyName(String name) {
42         WebElement propertyNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_NAME.getValue());
43         propertyNameField.clear();
44         propertyNameField.sendKeys(name);
45     }
46
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());
52         } else {
53             WebElement propertyValue = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_VALUE.getValue());
54             propertyValue.clear();
55             propertyValue.sendKeys(value);
56         }
57
58         GeneralUIUtils.ultimateWait();
59     }
60
61     public void insertPropertyDescription(String description) {
62         WebElement propertyDescription = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_DESCRIPTION.getValue());
63         propertyDescription.clear();
64         propertyDescription.sendKeys(description);
65     }
66
67     public void selectPropertyType(String propertyType) {
68         boolean isEntrySchemaDisplayed;
69         try {
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);
74             }
75         } catch (NoSuchElementException e) {
76
77         }
78     }
79
80     public void selectEntrySchema(String propertyType) {
81         GeneralUIUtils.getSelectList(propertyType, DataTestIdEnum.PropertiesPopupEnum.ENTRY_SCHEMA.getValue());
82     }
83
84     public void clickAdd() {
85         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.ADD.getValue());
86         //GeneralUIUtils.ultimateWait();
87     }
88
89     public void clickSave() {
90         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.SAVE.getValue());
91         getPopupForm();
92     }
93
94     public void clickCancel() {
95         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.CANCEL.getValue());
96         //GeneralUIUtils.ultimateWait();
97     }
98
99     public void clickDone() {
100         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.DONE.getValue());
101         //GeneralUIUtils.ultimateWait();
102     }
103
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();
106     }
107
108 }