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.openecomp.sdc.ci.tests.pages;
23 import java.util.ArrayList;
24 import java.util.List;
26 import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails;
27 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
28 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
29 import org.openqa.selenium.Keys;
30 import org.openqa.selenium.WebElement;
33 public class ResourceGeneralPage extends GeneralPageElements {
35 public ResourceGeneralPage() {
39 public static WebElement getNameField() {
40 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.RESOURCE_NAME.getValue());
43 public static WebElement getDescriptionField() {
44 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.DESCRIPTION.getValue());
47 public static String getCategoryDataTestsIdAttribute() {
48 return DataTestIdEnum.ResourceMetadataEnum.CATEGORY.getValue();
51 public static WebElement getVendorNameField() {
52 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_NAME.getValue());
55 public static WebElement getVendorReleaseField() {
56 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_RELEASE.getValue());
59 public static WebElement getTagsField() {
60 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS.getValue());
63 public static WebElement getContactIdField() {
64 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.CONTACT_ID.getValue());
67 /***************************************************************/
69 public static String getNameText() {
70 return getNameField().getAttribute("value");
73 public static void defineName(String resourceName) {
74 WebElement resourceNameTextbox = getNameField();
75 resourceNameTextbox.clear();
76 resourceNameTextbox.sendKeys(resourceName);
79 public static void defineNameWithPaste() {
80 defineTextBoxWithPaste(getNameField());
83 public static String getDescriptionText() {
84 return getDescriptionField().getAttribute("value");
87 public static void defineDescription(String description) {
88 WebElement descriptionTextbox = getDescriptionField();
89 descriptionTextbox.clear();
90 descriptionTextbox.sendKeys(description);
93 public static void defineDescriptionWithPaste() {
94 defineTextBoxWithPaste(getDescriptionField());
97 public static String getVendorNameText() {
98 return getVendorNameField().getAttribute("value");
101 public static void defineVendorName(String vendorName) {
102 WebElement vendorNameTextbox = getVendorNameField();
103 vendorNameTextbox.clear();
104 vendorNameTextbox.sendKeys(vendorName);
107 public static void defineVendorNameWithPaste() {
108 defineTextBoxWithPaste(getVendorNameField());
111 public static String getVendorReleaseText() {
112 return getVendorReleaseField().getAttribute("value");
115 public static void defineVendorRelease(String vendorRelease) {
116 WebElement vendorReleaseTextbox = getVendorReleaseField();
117 vendorReleaseTextbox.clear();
118 vendorReleaseTextbox.sendKeys(vendorRelease);
121 public static void defineVendorReleaseWithPaste() {
122 defineTextBoxWithPaste(getVendorReleaseField());
125 public static void defineTag(String resourceTags) {
126 WebElement tagTextbox = getTagsField();
128 tagTextbox.sendKeys(resourceTags);
129 tagTextbox.sendKeys(Keys.ENTER);
132 public static void defineTagsList(ComponentReqDetails component, String[] tags) {
133 List<String> taglist = new ArrayList<String>();
134 WebElement resourceTagsTextbox = getTagsField();
135 for (String tag : tags) {
136 resourceTagsTextbox.clear();
137 resourceTagsTextbox.sendKeys(tag);
138 GeneralUIUtils.sleep(500);
139 resourceTagsTextbox.sendKeys(Keys.ENTER);
142 component.getTags().addAll(taglist);
145 public static void defineTagsListWithPaste() {
146 List<String> taglist = new ArrayList<String>();
147 WebElement resourceTagsTextbox = getTagsField();
148 defineTextBoxWithPaste(resourceTagsTextbox);
149 resourceTagsTextbox.sendKeys(Keys.ENTER);
152 public static void defineCategory(String category) {
153 GeneralUIUtils.getSelectList(category, getCategoryDataTestsIdAttribute());
156 public static String getContactIdText() {
157 return getContactIdField().getAttribute("value");
160 public static void defineContactId(String userId) {
161 WebElement contactIdTextbox = getContactIdField();
162 contactIdTextbox.clear();
163 contactIdTextbox.sendKeys(userId);
164 GeneralUIUtils.waitForLoader();
167 public static List<WebElement> getElementsFromTagsTable(){
168 return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS_TABLE.getValue());
171 public static void defineTextBoxWithPaste(WebElement textBox) {
173 textBox.sendKeys(Keys.CONTROL + "v");
174 GeneralUIUtils.ultimateWait();