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.pages;
24 import java.util.List;
26 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
27 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.MainMenuButtonsFromInsideFrame;
28 import org.openecomp.sdc.ci.tests.utilities.DownloadManager;
29 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
30 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
31 import org.openqa.selenium.By;
32 import org.openqa.selenium.WebElement;
33 import org.openqa.selenium.support.ui.ExpectedConditions;
34 import org.openqa.selenium.support.ui.WebDriverWait;
36 public class HomePage extends GeneralPageElements {
42 public static void showVspRepository(){
43 GeneralUIUtils.waitForElementInVisibilityBy(By.className("ui-notification"), 30);
44 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.MainMenuButtons.REPOSITORY_ICON.getValue());
47 public static boolean searchForVSP(String vspName){
48 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ImportVfRepository.SEARCH.getValue()).sendKeys(vspName);
49 GeneralUIUtils.ultimateWait();
50 // return checkElementsCountInTable(2);
54 public static void importVSP(String vspName){
55 HomePage.showVspRepository();
56 boolean vspFound = HomePage.searchForVSP(vspName);
58 List<WebElement> elemenetsFromTable = getElemenetsFromTable();
59 // GeneralUIUtils.waitForLoader();
60 WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 30);
61 WebElement findElement = wait.until(ExpectedConditions.visibilityOf(elemenetsFromTable.get(1)));
63 GeneralUIUtils.waitForLoader();
64 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.IMPORT_VSP.getValue());
65 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue());
66 GeneralUIUtils.waitForLoader(60*10);
67 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue());
72 public static boolean navigateToHomePage() {
74 System.out.println("Searching for reporsitory icon.");
75 WebElement repositoryIcon = GeneralUIUtils.getInputElement("repository-icon");
76 if (repositoryIcon != null){
80 GeneralUIUtils.ultimateWait();
81 List<WebElement> homeButtons = GeneralUIUtils.getElemenetsFromTable(By.xpath("//a[contains(.,'HOME')]"));
82 if (homeButtons.size() != 0){
83 for (WebElement home : homeButtons){
84 if (home.isDisplayed()){
86 System.out.println("Clicked on home button");
90 GeneralUIUtils.closeErrorMessage();
91 WebElement homeButton = GeneralUIUtils.getInputElement(DataTestIdEnum.MainMenuButtons.HOME_BUTTON.getValue());
92 return homeButton.isDisplayed();
97 catch(Exception innerException){
98 System.out.println("Can't click on home button.");
104 public static File downloadVspCsarToDefaultDirectory(String vspName) throws Exception {
105 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click();
106 DownloadManager.downloadCsarByNameFromVSPRepository(vspName, "");
107 File latestFilefromDir = FileHandling.getLastModifiedFileFromDir();
108 return latestFilefromDir;