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 / OnboardHeaderComponent.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 import lombok.AllArgsConstructor;
23 import lombok.Getter;
24 import org.openqa.selenium.By;
25 import org.openqa.selenium.WebDriver;
26 import org.openqa.selenium.WebElement;
27 import org.openqa.selenium.support.ui.ExpectedConditions;
28
29 /**
30  * Handles the Onboard Header Component UI test actions
31  */
32 public class OnboardHeaderComponent extends AbstractPageObject {
33
34     private WebElement wrappingElement;
35
36     public OnboardHeaderComponent(final WebDriver webDriver) {
37         super(webDriver);
38     }
39
40     @Override
41     public void isLoaded() {
42         wrappingElement = getWait()
43             .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.MAIN_DIV.getXpath())));
44         getWait()
45             .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.WORKSPACE_TAB_DIV.getXpath())));
46         getWait()
47             .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.ONBOARD_TAB_DIV.getXpath())));
48     }
49
50     /**
51      * Clicks on the workspace tab.
52      */
53     public void clickOnWorkspaceTab() {
54         wrappingElement.findElement(By.xpath(XpathSelector.WORKSPACE_TAB_DIV.getXpath()));
55     }
56
57     /**
58      * Clicks on the workspace tab.
59      */
60     public void clickOnOnboardTab() {
61         wrappingElement.findElement(By.xpath(XpathSelector.ONBOARD_TAB_DIV.getXpath()));
62     }
63
64     /**
65      * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
66      */
67     @AllArgsConstructor
68     private enum XpathSelector {
69         MAIN_DIV("onboard-header", "//div[contains(@class, '%s')]"),
70         WORKSPACE_TAB_DIV("onboard-workspace-tab", "//div[@data-test-id='%s']"),
71         ONBOARD_TAB_DIV("onboard-onboard-tab", "//div[@data-test-id='%s']");
72
73         @Getter
74         private final String id;
75         private final String xpathFormat;
76
77         public String getXpath() {
78             return String.format(xpathFormat, id);
79         }
80     }
81
82 }