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.ToscaArtifactsPage;
26 import org.openqa.selenium.By;
27 import org.openqa.selenium.WebDriver;
28 import org.openqa.selenium.WebElement;
31 * Handles the Resource Page Left Side Menu UI actions
33 public class ResourceLeftSideMenu extends AbstractPageObject {
35 private WebElement wrappingElement;
37 public ResourceLeftSideMenu(final WebDriver webDriver) {
43 public void isLoaded() {
44 wrappingElement = getWrappingElement();
45 waitToBeClickable(By.xpath(XpathSelector.GENERAL_MENU.getXpath()));
49 * Gets the enclosing element of the menu.
51 * @return the enclosing element
53 public WebElement getWrappingElement() {
54 return waitForElementVisibility(By.className(XpathSelector.MAIN_DIV.getId()));
58 * Clicks on the properties assignment menu item.
60 * @return the next page object
62 public ResourcePropertiesAssignmentPage clickOnPropertiesAssignmentMenuItem() {
63 wrappingElement.findElement(By.xpath(XpathSelector.PROPERTIES_ASSIGNMENT_MENU.getXpath())).click();
64 return new ResourcePropertiesAssignmentPage(webDriver);
68 * Clicks on the 'Attributes & Outputs' menu item.
70 * @return the next page object
72 public AttributesOutputsPage clickOnAttributesOutputsMenuItem() {
73 wrappingElement.findElement(By.xpath(XpathSelector.ATTRIBUTES_OUTPUTS_MENU.getXpath())).click();
74 return new AttributesOutputsPage(webDriver);
78 * Clicks on the 'Attributes' menu item.
80 * @return the next page object
82 public AttributesPage clickOnAttributesMenuItem() {
83 wrappingElement.findElement(By.xpath(XpathSelector.ATTRIBUTES_MENU.getXpath())).click();
84 return new AttributesPage(webDriver);
88 * Clicks on the TOSCA artifacts menu item.
90 * @return the next page object
92 public ToscaArtifactsPage clickOnToscaArtifactsMenuItem() {
93 wrappingElement.findElement(By.xpath(XpathSelector.TOSCA_ARTIFACTS_MENU.getXpath())).click();
94 return new ToscaArtifactsPage(webDriver);
98 * Clicks on the 'General' menu item.
100 * @return the next page object
102 public <T extends ComponentPage> T clickOnGeneralMenuItem(Class<? extends T> clazz) {
103 wrappingElement.findElement(By.xpath(XpathSelector.GENERAL_MENU.getXpath())).click();
104 return (T) new ComponentPage(webDriver);
107 public CompositionPage clickOnCompositionMenuItem() {
108 wrappingElement.findElement(By.xpath(XpathSelector.COMPOSITION_MENU.getXpath())).click();
109 return new CompositionPage(webDriver);
112 public ResourcePropertiesPage clickOnPropertiesMenuItem() {
113 wrappingElement.findElement(By.xpath(XpathSelector.PROPERTIES_MENU.getXpath())).click();
114 return new ResourcePropertiesPage(webDriver);
118 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
121 private enum XpathSelector {
122 MAIN_DIV("w-sdc-left-sidebar", "//div[@class='%s']"),
123 PROPERTIES_ASSIGNMENT_MENU("Properties AssignmentLeftSideMenu", "//*[@data-tests-id='%s']"),
124 PROPERTIES_MENU("PropertiesLeftSideMenu", "//*[@data-tests-id='%s']"),
125 ATTRIBUTES_OUTPUTS_MENU("Attributes & OutputsLeftSideMenu", "//*[@data-tests-id='%s']"),
126 ATTRIBUTES_MENU("AttributesLeftSideMenu", "//*[@data-tests-id='%s']"),
127 GENERAL_MENU("GeneralLeftSideMenu", "//*[@data-tests-id='%s']"),
128 COMPOSITION_MENU("CompositionLeftSideMenu", "//*[@data-tests-id='%s']"),
129 REQUIREMENT_CAPABILITY_MENU("Req. & CapabilitiesLeftSideMenu", "//*[@data-tests-id='%s']"),
130 TOSCA_ARTIFACTS_MENU("TOSCA ArtifactsLeftSideMenu", "//*[@data-tests-id='%s']");
133 private final String id;
134 private final String xpathFormat;
136 public String getXpath() {
137 return String.format(xpathFormat, id);