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