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