Provide user to specify the ouput name while declaring the atrributes
[sdc.git] / integration-tests / src / test / java / org / onap / sdc / frontend / ci / tests / pages / OnboardHomePage.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  *
16  *  SPDX-License-Identifier: Apache-2.0
17  *  ============LICENSE_END=========================================================
18  */
19
20 package org.onap.sdc.frontend.ci.tests.pages;
21
22
23 import lombok.AllArgsConstructor;
24 import lombok.Getter;
25 import org.openqa.selenium.By;
26 import org.openqa.selenium.WebDriver;
27 import org.openqa.selenium.WebElement;
28 import org.openqa.selenium.support.ui.ExpectedConditions;
29
30 /**
31  * Handles the Onboard Home Page UI test actions
32  */
33 public class OnboardHomePage extends AbstractPageObject {
34
35     private final OnboardHeaderComponent onboardHeaderComponent;
36     private WebElement createNewVspBtn;
37     private WebElement createNewVlmBtn;
38
39     public OnboardHomePage(final WebDriver webDriver,
40                            final OnboardHeaderComponent onboardHeaderComponent) {
41         super(webDriver);
42         this.onboardHeaderComponent = onboardHeaderComponent;
43     }
44
45     @Override
46     public void isLoaded() {
47         onboardHeaderComponent.isLoaded();
48         createNewVspBtn = getWait()
49             .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.ADD_NEW_VSP_BTN.getXpath())));
50
51         createNewVlmBtn = getWait()
52             .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.ADD_NEW_VLM_BTN.getXpath())));
53     }
54
55     /**
56      * Clicks on the button create new vsp.
57      *
58      * @return returns the next vsp creation page object
59      */
60     public VspCreationModal clickOnCreateNewVsp() {
61         waitForElementInvisibility(By.xpath(XpathSelector.ONBOARDING_LOADER_DIV.getXpath()));
62         createNewVspBtn.click();
63         return new VspCreationModal(webDriver);
64     }
65
66
67     /**
68      * Clicks on the button create new vlm.
69      *
70      * @return returns the next vlm creation page object
71      */
72     public VlmCreationModal clickOnCreateNewVlm() {
73         waitForElementInvisibility(By.xpath(XpathSelector.ONBOARDING_LOADER_DIV.getXpath()));
74         createNewVlmBtn.click();
75         return new VlmCreationModal(webDriver);
76     }
77
78     /**
79      * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
80      */
81     @AllArgsConstructor
82     private enum XpathSelector {
83         ADD_NEW_VSP_BTN("catalog-add-new-vsp", "//div[@data-test-id='%s']"),
84         ADD_NEW_VLM_BTN("catalog-add-new-vlm", "//div[@data-test-id='%s']"),
85         ONBOARDING_LOADER_DIV("onboarding-loader-backdrop","//div[@class='%s']");
86
87         @Getter
88         private final String id;
89         private final String xpathFormat;
90
91         public String getXpath() {
92             return String.format(xpathFormat, id);
93         }
94     }
95
96 }