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