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