Catalog alignment
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / 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.openecomp.sdc.ci.tests.pages;
21
22 import org.openqa.selenium.By;
23 import org.openqa.selenium.WebDriver;
24 import org.openqa.selenium.WebElement;
25 import org.openqa.selenium.support.ui.ExpectedConditions;
26
27 import static org.openecomp.sdc.ci.tests.pages.OnboardHomePage.XpathSelector.ADD_NEW_VLM_BTN;
28 import static org.openecomp.sdc.ci.tests.pages.OnboardHomePage.XpathSelector.ADD_NEW_VSP_BTN;
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
38     public OnboardHomePage(final WebDriver webDriver,
39                            final OnboardHeaderComponent onboardHeaderComponent) {
40         super(webDriver);
41         this.onboardHeaderComponent = onboardHeaderComponent;
42     }
43
44     @Override
45     public void isLoaded() {
46         onboardHeaderComponent.isLoaded();
47         createNewVspBtn = getWait()
48             .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(ADD_NEW_VSP_BTN.getXpath())));
49         getWait()
50             .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(ADD_NEW_VLM_BTN.getXpath())));
51     }
52
53     /**
54      * Clicks on the button create new vsp.
55      *
56      * @return returns the next vsp creation page object
57      */
58     public VspCreationModal clickOnCreateNewVsp() {
59         createNewVspBtn.click();
60         return new VspCreationModal(webDriver);
61     }
62
63     /**
64      * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
65      */
66     public enum XpathSelector {
67         ADD_NEW_VSP_BTN("catalog-add-new-vsp", "//div[@data-test-id='%s']"),
68         ADD_NEW_VLM_BTN("catalog-add-new-vlm", "//div[@data-test-id='%s']");
69
70         private final String id;
71         private final String xpathFormat;
72
73         XpathSelector(final String id, final String xpathFormat) {
74             this.id = id;
75             this.xpathFormat = xpathFormat;
76         }
77
78         public String getId() {
79             return id;
80         }
81
82         public String getXpath() {
83             return String.format(xpathFormat, id);
84         }
85     }
86
87 }