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 org.onap.sdc.backend.ci.tests.datatypes.ComponentReqDetails;
24 import org.onap.sdc.frontend.ci.tests.datatypes.DataTestIdEnum;
25 import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils;
26 import org.openqa.selenium.Keys;
27 import org.openqa.selenium.WebElement;
29 import java.util.ArrayList;
30 import java.util.List;
33 public class ResourceGeneralPage extends GeneralPageElements {
35 private static final int SLEEP_DURATION = 500;
37 protected ResourceGeneralPage() {
41 public static WebElement getNameField() {
42 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.RESOURCE_NAME.getValue());
45 public static WebElement getDescriptionField() {
46 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.DESCRIPTION.getValue());
49 public static String getModelDataTestsIdAttribute() {
50 return DataTestIdEnum.ResourceMetadataEnum.MODEL.getValue();
53 public static String getCategoryDataTestsIdAttribute() {
54 return DataTestIdEnum.ResourceMetadataEnum.CATEGORY.getValue();
57 public static WebElement getVendorNameField() {
58 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_NAME.getValue());
61 public static WebElement getVendorReleaseField() {
62 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_RELEASE.getValue());
65 public static WebElement getTagsField() {
66 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS.getValue());
69 public static WebElement getContactIdField() {
70 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.CONTACT_ID.getValue());
73 /***************************************************************/
75 public static String getNameText() {
76 return getNameField().getAttribute("value");
79 public static void defineName(String resourceName) {
80 WebElement resourceNameTextbox = getNameField();
81 resourceNameTextbox.clear();
82 resourceNameTextbox.sendKeys(resourceName);
85 public static void defineNameWithPaste() {
86 defineTextBoxWithPaste(getNameField());
89 public static String getDescriptionText() {
90 return getDescriptionField().getAttribute("value");
93 public static void defineDescription(String description) {
94 WebElement descriptionTextbox = getDescriptionField();
95 descriptionTextbox.clear();
96 descriptionTextbox.sendKeys(description);
99 public static void defineDescriptionWithPaste() {
100 defineTextBoxWithPaste(getDescriptionField());
103 public static String getVendorNameText() {
104 return getVendorNameField().getAttribute("value");
107 public static void defineVendorName(String vendorName) {
108 WebElement vendorNameTextbox = getVendorNameField();
109 vendorNameTextbox.clear();
110 vendorNameTextbox.sendKeys(vendorName);
113 public static void defineVendorNameWithPaste() {
114 defineTextBoxWithPaste(getVendorNameField());
117 public static String getVendorReleaseText() {
118 return getVendorReleaseField().getAttribute("value");
121 public static void defineVendorRelease(String vendorRelease) {
122 WebElement vendorReleaseTextbox = getVendorReleaseField();
123 vendorReleaseTextbox.clear();
124 vendorReleaseTextbox.sendKeys(vendorRelease);
127 public static void defineVendorReleaseWithPaste() {
128 defineTextBoxWithPaste(getVendorReleaseField());
131 public static void defineTag(String resourceTags) {
132 WebElement tagTextbox = getTagsField();
134 tagTextbox.sendKeys(resourceTags);
135 tagTextbox.sendKeys(Keys.ENTER);
138 public static void defineTagsList(ComponentReqDetails component, String[] tags) {
139 List<String> taglist = new ArrayList<String>();
140 WebElement resourceTagsTextbox = getTagsField();
141 for (String tag : tags) {
142 resourceTagsTextbox.clear();
143 resourceTagsTextbox.sendKeys(tag);
144 GeneralUIUtils.sleep(SLEEP_DURATION);
145 resourceTagsTextbox.sendKeys(Keys.ENTER);
148 component.getTags().addAll(taglist);
151 public static void defineTagsListWithPaste() {
152 List<String> taglist = new ArrayList<String>();
153 WebElement resourceTagsTextbox = getTagsField();
154 defineTextBoxWithPaste(resourceTagsTextbox);
155 resourceTagsTextbox.sendKeys(Keys.ENTER);
158 public static void defineCategory(String category) {
159 GeneralUIUtils.getSelectList(category, getCategoryDataTestsIdAttribute());
162 public static String getContactIdText() {
163 return getContactIdField().getAttribute("value");
166 public static void defineContactId(String userId) {
167 WebElement contactIdTextbox = getContactIdField();
168 contactIdTextbox.clear();
169 contactIdTextbox.sendKeys(userId);
170 GeneralUIUtils.waitForLoader();
173 public static List<WebElement> getElementsFromTagsTable() {
174 return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS_TABLE.getValue());
177 public static void defineTextBoxWithPaste(WebElement textBox) {
179 textBox.sendKeys(Keys.CONTROL + "v");
180 GeneralUIUtils.ultimateWait();
183 public static void moveToToscaArtifactsSectionAndDownloadTosca() {
184 getLeftMenu().moveToToscaArtifactsScreen();
185 ToscaArtifactsPage.downloadCsar();
188 public static String getVersionUI() {
189 String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText().replace("V", "");
190 return actualVersion;