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.utilities;
23 import com.aventstack.extentreports.Status;
24 import org.openecomp.sdc.be.model.User;
25 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
27 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
28 import org.openecomp.sdc.ci.tests.pages.GeneralPageElements;
29 import org.openecomp.sdc.ci.tests.pages.ProductGeneralPage;
30 import org.openqa.selenium.Keys;
31 import org.openqa.selenium.WebDriver;
32 import org.openqa.selenium.WebElement;
34 import java.util.List;
40 public class ProductUIUtils {
42 protected static WebDriver driver;
44 private ProductUIUtils() {
48 private static void fillProductGeneralPage(ProductReqDetails product, User user) throws Exception {
49 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Fill in metadata values in general page.. "));
50 ProductGeneralPage.defineName(product.getName());
51 ProductGeneralPage.defineFullName(product.getFullName());
52 ProductGeneralPage.defineDescription(product.getDescription());
53 ProductGeneralPage.defineProjectCode(product.getProjectCode());
54 defineTagsList2(product.getTags());
55 ProductGeneralPage.defineContactId(product.getContactId());
56 GeneralUIUtils.clickSomewhereOnPage();
59 public static void createProduct(ProductReqDetails product, User user) throws Exception {
61 fillProductGeneralPage(product, user);
62 GeneralPageElements.clickCreateButton();
63 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Product %s created", product.getName()));
66 private static void defineTagsList2(List<String> productTags) {
67 WebElement productTagsTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.TAGS.getValue());
68 for (String tag : productTags) {
69 productTagsTextbox.clear();
70 productTagsTextbox.sendKeys(tag);
71 GeneralUIUtils.waitForAngular();
72 productTagsTextbox.sendKeys(Keys.ENTER);
76 private static void clikAddProduct() {
77 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking Add Product button"));
79 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.Dashboard.ADD_AREA.getValue());
80 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_PRODUCT.getValue()).click();
81 GeneralUIUtils.ultimateWait();
82 } catch (Exception e) {
83 SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exception on catched on Add Product button, retrying ..."));
84 GeneralUIUtils.hoverOnAreaByClassName("w-sdc-dashboard-card-new");
85 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_PRODUCT.getValue()).click();
86 GeneralUIUtils.ultimateWait();