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 / ResourceLeftSideMenu.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.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage;
25 import org.onap.sdc.frontend.ci.tests.pages.component.workspace.InterfaceDefinitionPage;
26 import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage;
27 import org.openqa.selenium.By;
28 import org.openqa.selenium.WebDriver;
29 import org.openqa.selenium.WebElement;
30
31 /**
32  * Handles the Resource Page Left Side Menu UI actions
33  */
34 public class ResourceLeftSideMenu extends AbstractPageObject {
35
36     private WebElement wrappingElement;
37
38     public ResourceLeftSideMenu(final WebDriver webDriver) {
39         super(webDriver);
40         timeoutInSeconds = 5;
41     }
42
43     @Override
44     public void isLoaded() {
45         wrappingElement = getWrappingElement();
46         waitToBeClickable(By.xpath(XpathSelector.GENERAL_MENU.getXpath()));
47     }
48
49     /**
50      * Gets the enclosing element of the menu.
51      *
52      * @return the enclosing element
53      */
54     public WebElement getWrappingElement() {
55         return waitForElementVisibility(By.className(XpathSelector.MAIN_DIV.getId()));
56     }
57
58     /**
59      * Clicks on the properties assignment menu item.
60      *
61      * @return the next page object
62      */
63     public ResourcePropertiesAssignmentPage clickOnPropertiesAssignmentMenuItem() {
64         wrappingElement.findElement(By.xpath(XpathSelector.PROPERTIES_ASSIGNMENT_MENU.getXpath())).click();
65         return new ResourcePropertiesAssignmentPage(webDriver);
66     }
67
68     /**
69      * Clicks on the 'Attributes & Outputs' menu item.
70      *
71      * @return the next page object
72      */
73     public AttributesOutputsPage clickOnAttributesOutputsMenuItem() {
74         wrappingElement.findElement(By.xpath(XpathSelector.ATTRIBUTES_OUTPUTS_MENU.getXpath())).click();
75         return new AttributesOutputsPage(webDriver);
76     }
77
78     /**
79      * Clicks on the 'Attributes' menu item.
80      *
81      * @return the next page object
82      */
83     public AttributesPage clickOnAttributesMenuItem() {
84         wrappingElement.findElement(By.xpath(XpathSelector.ATTRIBUTES_MENU.getXpath())).click();
85         return new AttributesPage(webDriver);
86     }
87
88     /**
89      * Clicks on the TOSCA artifacts menu item.
90      *
91      * @return the next page object
92      */
93     public ToscaArtifactsPage clickOnToscaArtifactsMenuItem() {
94         wrappingElement.findElement(By.xpath(XpathSelector.TOSCA_ARTIFACTS_MENU.getXpath())).click();
95         return new ToscaArtifactsPage(webDriver);
96     }
97
98     /**
99      * Clicks on the Interface Definition menu item.
100      *
101      * @return the next page object
102      */
103     public InterfaceDefinitionPage clickOnInterfaceDefinitionMenuItem() {
104         wrappingElement.findElement(By.xpath(XpathSelector.INTERFACE_DEFINITION_MENU.getXpath())).click();
105         return new InterfaceDefinitionPage(webDriver);
106     }
107
108     /**
109      * Clicks on the 'General' menu item.
110      *
111      * @return the next page object
112      */
113     public <T extends ComponentPage> T clickOnGeneralMenuItem(Class<? extends T> clazz) {
114         wrappingElement.findElement(By.xpath(XpathSelector.GENERAL_MENU.getXpath())).click();
115         return (T) new ComponentPage(webDriver);
116     }
117
118     public CompositionPage clickOnCompositionMenuItem() {
119         wrappingElement.findElement(By.xpath(XpathSelector.COMPOSITION_MENU.getXpath())).click();
120         return new CompositionPage(webDriver);
121     }
122
123     public ResourcePropertiesPage clickOnPropertiesMenuItem() {
124         wrappingElement.findElement(By.xpath(XpathSelector.PROPERTIES_MENU.getXpath())).click();
125         return new ResourcePropertiesPage(webDriver);
126     }
127
128     /**
129      * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
130      */
131     @AllArgsConstructor
132     private enum XpathSelector {
133         MAIN_DIV("w-sdc-left-sidebar", "//div[@class='%s']"),
134         PROPERTIES_ASSIGNMENT_MENU("Properties AssignmentLeftSideMenu", "//*[@data-tests-id='%s']"),
135         PROPERTIES_MENU("PropertiesLeftSideMenu", "//*[@data-tests-id='%s']"),
136         ATTRIBUTES_OUTPUTS_MENU("Attributes & OutputsLeftSideMenu", "//*[@data-tests-id='%s']"),
137         ATTRIBUTES_MENU("AttributesLeftSideMenu", "//*[@data-tests-id='%s']"),
138         GENERAL_MENU("GeneralLeftSideMenu", "//*[@data-tests-id='%s']"),
139         COMPOSITION_MENU("CompositionLeftSideMenu", "//*[@data-tests-id='%s']"),
140         REQUIREMENT_CAPABILITY_MENU("Req. & CapabilitiesLeftSideMenu", "//*[@data-tests-id='%s']"),
141         TOSCA_ARTIFACTS_MENU("TOSCA ArtifactsLeftSideMenu", "//*[@data-tests-id='%s']"),
142         INTERFACE_DEFINITION_MENU("InterfacesLeftSideMenu", "//*[@data-tests-id='%s']");
143
144         @Getter
145         private final String id;
146         private final String xpathFormat;
147
148         public String getXpath() {
149             return String.format(xpathFormat, id);
150         }
151     }
152
153 }