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
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.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
20 package org.onap.sdc.frontend.ci.tests.pages;
22 import lombok.AllArgsConstructor;
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;
32 * Handles the Resource Page Left Side Menu UI actions
34 public class ResourceLeftSideMenu extends AbstractPageObject {
36 private WebElement wrappingElement;
38 public ResourceLeftSideMenu(final WebDriver webDriver) {
44 public void isLoaded() {
45 wrappingElement = getWrappingElement();
46 waitToBeClickable(By.xpath(XpathSelector.GENERAL_MENU.getXpath()));
50 * Gets the enclosing element of the menu.
52 * @return the enclosing element
54 public WebElement getWrappingElement() {
55 return waitForElementVisibility(By.className(XpathSelector.MAIN_DIV.getId()));
59 * Clicks on the properties assignment menu item.
61 * @return the next page object
63 public ResourcePropertiesAssignmentPage clickOnPropertiesAssignmentMenuItem() {
64 wrappingElement.findElement(By.xpath(XpathSelector.PROPERTIES_ASSIGNMENT_MENU.getXpath())).click();
65 return new ResourcePropertiesAssignmentPage(webDriver);
69 * Clicks on the 'Attributes & Outputs' menu item.
71 * @return the next page object
73 public AttributesOutputsPage clickOnAttributesOutputsMenuItem() {
74 wrappingElement.findElement(By.xpath(XpathSelector.ATTRIBUTES_OUTPUTS_MENU.getXpath())).click();
75 return new AttributesOutputsPage(webDriver);
79 * Clicks on the 'Attributes' menu item.
81 * @return the next page object
83 public AttributesPage clickOnAttributesMenuItem() {
84 wrappingElement.findElement(By.xpath(XpathSelector.ATTRIBUTES_MENU.getXpath())).click();
85 return new AttributesPage(webDriver);
89 * Clicks on the TOSCA artifacts menu item.
91 * @return the next page object
93 public ToscaArtifactsPage clickOnToscaArtifactsMenuItem() {
94 wrappingElement.findElement(By.xpath(XpathSelector.TOSCA_ARTIFACTS_MENU.getXpath())).click();
95 return new ToscaArtifactsPage(webDriver);
99 * Clicks on the Interface Definition menu item.
101 * @return the next page object
103 public InterfaceDefinitionPage clickOnInterfaceDefinitionMenuItem() {
104 wrappingElement.findElement(By.xpath(XpathSelector.INTERFACE_DEFINITION_MENU.getXpath())).click();
105 return new InterfaceDefinitionPage(webDriver);
109 * Clicks on the 'General' menu item.
111 * @return the next page object
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);
118 public CompositionPage clickOnCompositionMenuItem() {
119 wrappingElement.findElement(By.xpath(XpathSelector.COMPOSITION_MENU.getXpath())).click();
120 return new CompositionPage(webDriver);
123 public ResourcePropertiesPage clickOnPropertiesMenuItem() {
124 wrappingElement.findElement(By.xpath(XpathSelector.PROPERTIES_MENU.getXpath())).click();
125 return new ResourcePropertiesPage(webDriver);
129 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
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']");
145 private final String id;
146 private final String xpathFormat;
148 public String getXpath() {
149 return String.format(xpathFormat, id);