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.ci.tests.datatypes.CheckBoxStatusEnum;
25 import org.openecomp.sdc.ci.tests.datatypes.CreateAndImportButtonsEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
27 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
28 import org.openqa.selenium.By;
29 import org.openqa.selenium.WebDriver;
30 import org.openqa.selenium.WebElement;
31 import org.testng.Assert;
33 import java.util.List;
35 public final class HomeUtils {
37 public static WebElement createAndImportButtons(CreateAndImportButtonsEnum type, WebDriver driver)
38 throws InterruptedException {
43 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.Dashboard.IMPORT_AREA.getValue());
44 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.IMPORT_VFC.getValue());
47 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.Dashboard.IMPORT_AREA.getValue());
48 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.IMPORT_VFC.getValue());
50 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.Dashboard.ADD_AREA.getValue());
51 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_SERVICE.getValue()).click();
56 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_SERVICE.getValue()).click();
57 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_SERVICE.getValue()).click();
61 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.Dashboard.ADD_AREA.getValue());
62 driver.findElement(By.xpath("//*[@data-tests-id='createResourceButton']")).click();
69 public static String checkBoxLifeCyclestate(CheckBoxStatusEnum lifeCycle) {
70 String Status = "IN DESIGN CHECK OUT";
73 Status = "IN DESIGN CHECK IN";
74 if (GeneralUIUtils.getWebElementByTestID(lifeCycle.getValue()).isDisplayed()) {
75 GeneralUIUtils.getWebElementByTestID(lifeCycle.getValue()).click();
79 GeneralUIUtils.getWebElementByTestID(lifeCycle.getValue()).click();
80 Status = "IN DESIGN CHECK OUT";
83 GeneralUIUtils.getWebElementByTestID(lifeCycle.getValue()).click();
84 Status = "IN TESTING";
86 case READY_FOR_TESTING:
87 GeneralUIUtils.getWebElementByTestID(lifeCycle.getValue()).click();
88 Status = "READY FOR TESTING";
91 GeneralUIUtils.getWebElementByTestID(lifeCycle.getValue()).click();
98 public static void findComponentAndClick(String componentName) throws Exception {
99 SetupCDTest.getExtendTest().log(Status.INFO, "finding component " + componentName);
100 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()).sendKeys(componentName);
101 WebElement foundComp = null;
103 foundComp = GeneralUIUtils.getWebElementByTestID(componentName);
105 GeneralUIUtils.waitForLoader();
106 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
107 } catch (Exception e) {
108 String msg = String.format("DID NOT FIND A COMPONENT NAMED %s", componentName);
109 SetupCDTest.getExtendTest().log(Status.FAIL, msg);
110 System.out.println(msg);
115 public static void findComponentAndClickByVersion(String componentName, String version) throws Exception {
116 SetupCDTest.getExtendTest().log(Status.INFO, String.format("finding component %s v%s", componentName, version));
117 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()).sendKeys(componentName);
118 List<WebElement> foundComp = null;
120 foundComp = GeneralUIUtils.getWebElementsListByTestID(componentName + "Version");
122 for (WebElement webElement : foundComp)
124 if(webElement.getText().contains(version))
127 GeneralUIUtils.ultimateWait();
131 } catch (Exception e) {
132 String msg = String.format("DID NOT FIND A COMPONENT NAMED %s", componentName);
133 SetupCDTest.getExtendTest().log(Status.FAIL, msg);
134 System.out.println(msg);