2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.sdc.ci.tests.utilities;
\r
23 import com.aventstack.extentreports.Status;
\r
24 import org.openecomp.sdc.ci.tests.datatypes.CreateAndImportButtonsEnum;
\r
25 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
\r
26 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
\r
27 import org.openqa.selenium.By;
\r
28 import org.openqa.selenium.WebDriver;
\r
29 import org.openqa.selenium.WebElement;
\r
30 import org.testng.Assert;
\r
32 import java.util.List;
\r
34 public final class HomeUtils {
\r
36 public static WebElement createAndImportButtons(CreateAndImportButtonsEnum type, WebDriver driver)
\r
37 throws InterruptedException {
\r
43 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.Dashboard.IMPORT_AREA.getValue());
\r
44 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.IMPORT_VFC.getValue());
\r
45 case CREATE_SERVICE:
\r
46 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.Dashboard.ADD_AREA.getValue());
\r
47 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_SERVICE.getValue()).click();
\r
50 case CREATE_PRODUCT:
\r
51 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_SERVICE.getValue()).click();
\r
52 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_SERVICE.getValue()).click();
\r
56 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.Dashboard.ADD_AREA.getValue());
\r
57 driver.findElement(By.xpath("//*[@data-tests-id='createResourceButton']")).click();
\r
64 public static void findComponentAndClick(String componentName) throws Exception {
\r
65 SetupCDTest.getExtendTest().log(Status.INFO, "finding component " + componentName);
\r
66 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()).sendKeys(componentName);
\r
67 WebElement foundComp = null;
\r
69 foundComp = GeneralUIUtils.getWebElementByTestID(componentName);
\r
71 GeneralUIUtils.waitForLoader();
\r
72 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
\r
73 } catch (Exception e) {
\r
74 String msg = String.format("DID NOT FIND A COMPONENT NAMED %s", componentName);
\r
75 SetupCDTest.getExtendTest().log(Status.FAIL, msg);
\r
76 System.out.println(msg);
\r
81 public static void findComponentAndClickByVersion(String componentName, String version) throws Exception {
\r
82 SetupCDTest.getExtendTest().log(Status.INFO, String.format("finding component %s v%s", componentName, version));
\r
83 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()).sendKeys(componentName);
\r
84 List<WebElement> foundComp = null;
\r
86 foundComp = GeneralUIUtils.getWebElementsListByTestID(componentName + "Version");
\r
88 for (WebElement webElement : foundComp) {
\r
89 if (webElement.getText().contains(version)) {
\r
91 GeneralUIUtils.ultimateWait();
\r
95 } catch (Exception e) {
\r
96 String msg = String.format("DID NOT FIND A COMPONENT NAMED %s", componentName);
\r
97 SetupCDTest.getExtendTest().log(Status.FAIL, msg);
\r
98 System.out.println(msg);
\r