re base code
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / 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.openecomp.sdc.ci.tests.pages;
22
23 import com.aventstack.extentreports.Status;
24 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
25 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
26 import org.openecomp.sdc.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         public PropertyPopup() {
36         }
37
38         public boolean getPopupForm(){
39                 return GeneralUIUtils.waitForElementInVisibilityByTestId(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue(), 60);
40         }
41         
42         public void insertPropertyName(String name) {
43                 WebElement propertyNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_NAME.getValue());
44                 propertyNameField.clear();
45                 propertyNameField.sendKeys(name);
46         }
47
48         public void insertPropertyDefaultValue(String value) {
49                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Inserting to property default value: %s ", value));
50                 WebElement selectedType = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue())).getFirstSelectedOption();
51                 if(selectedType.getText().equals("boolean")) {
52                         GeneralUIUtils.getSelectList(value, DataTestIdEnum.PropertiesPopupEnum.PROPERTY_BOOLEAN_VALUE.getValue());
53                 } else {
54                         WebElement propertyValue = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_VALUE.getValue());
55                         propertyValue.clear();
56                         propertyValue.sendKeys(value);
57                 }       
58                 
59                 GeneralUIUtils.ultimateWait();
60         }
61
62         public void insertPropertyDescription(String description) {
63                 WebElement propertyDescription = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_DESCRIPTION.getValue());
64                 propertyDescription.clear();
65                 propertyDescription.sendKeys(description);
66         }
67
68         public void selectPropertyType(String propertyType) {
69                 boolean isEntrySchemaDisplayed;
70                 try{
71                         GeneralUIUtils.getSelectList(propertyType, DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue());
72                         isEntrySchemaDisplayed = GeneralUIUtils.getDriver().findElement(By.xpath(DataTestIdEnum.PropertiesPopupEnum.ENTRY_SCHEMA.getValue())).isDisplayed();
73                         if (isEntrySchemaDisplayed){
74                                 PropertiesPage.getPropertyPopup().selectEntrySchema(propertyType);
75                         }
76                 }
77                 catch(NoSuchElementException e){
78                         
79                 }
80         }
81         
82         public void selectEntrySchema(String propertyType){
83                 GeneralUIUtils.getSelectList(propertyType, DataTestIdEnum.PropertiesPopupEnum.ENTRY_SCHEMA.getValue());
84         }
85
86         public void clickAdd() {
87                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.ADD.getValue());
88 //              GeneralUIUtils.ultimateWait();
89         }
90
91         public void clickSave() {
92                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.SAVE.getValue());
93                 getPopupForm();
94         }
95
96         public void clickCancel() {
97                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.CANCEL.getValue());
98 //              GeneralUIUtils.ultimateWait();
99         }
100
101         public void clickDone() {
102                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.DONE.getValue());
103 //              GeneralUIUtils.ultimateWait();
104         }
105         
106         public void selectPropertyRadioButton(String propertyName) {
107                 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_RADIO_BUTTON_CONTAINER.getValue() + propertyName).findElement(By.className(DataTestIdEnum.PropertiesPopupEnum.RADIO_BUTTON_CLASS.getValue())).click();
108         }
109
110 }