2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 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.component.workspace;
22 import static org.hamcrest.MatcherAssert.assertThat;
23 import static org.hamcrest.Matchers.is;
25 import lombok.AllArgsConstructor;
27 import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject;
28 import org.openqa.selenium.By;
29 import org.openqa.selenium.Dimension;
30 import org.openqa.selenium.WebDriver;
31 import org.openqa.selenium.WebElement;
33 public class CompositionDetailSideBarComponent extends AbstractPageObject {
35 private WebElement wrappingElement;
37 public CompositionDetailSideBarComponent(final WebDriver webDriver) {
42 public void isLoaded() {
43 wrappingElement = waitForElementVisibility(By.xpath(XpathSelector.MAIN_ELEMENT_DIV.getXpath()));
46 public String getSelectedComponentName() {
47 return wrappingElement.findElement(By.xpath(XpathSelector.DETAIL_COMPONENT_NAME_DIV.getXpath())).getText();
50 public void checkComponentIsSelected(final String componentName) {
51 assertThat("The selected component should be as expected", getSelectedComponentName(), is(componentName));
54 public Dimension getSize() {
55 final WebElement sideBarToggle = waitForElementVisibility(XpathSelector.DETAIL_SIDE_BAR_TOGGLE_DIV.getXpath());
56 if (!sideBarToggle.getAttribute("class").contains("active")) {
57 return new Dimension(0, 0);
60 return wrappingElement.getSize();
63 public AbstractPageObject selectTab(final CompositionDetailTabName tabName) {
64 final WebElement tabElement = wrappingElement.findElement(By.xpath(tabName.getXpathSelector().getXpath()));
68 return new CompositionInformationTab(webDriver);
70 return new CompositionInputsTab(webDriver);
71 case DEPLOYMENT_ARTIFACTS:
72 return new CompositionDeploymentArtifactsTab(webDriver);
73 case INFORMATIONAL_ARTIFACTS:
74 return new CompositionInformationalArtifactsTab(webDriver);
76 return new CompositionApiArtifactsTab(webDriver);
77 case SUBSTITUTION_FILTER:
78 return new CompositionSubstitutionFilterTab(webDriver);
79 case REQUIREMENTS_CAPABILITIES:
80 return new CompositionRequirementsCapabilitiesTab(webDriver);
81 case INTERFACE_OPERATIONS:
82 return new CompositionInterfaceOperationsTab(webDriver);
84 throw new IllegalStateException("Not yet implemented: " + tabName);
89 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
92 private enum XpathSelector {
93 MAIN_ELEMENT_DIV("w-sdc-designer-sidebar", "//div[@class='%s']"),
94 DETAIL_SIDE_BAR_TOGGLE_DIV("w-sdc-designer-sidebar-toggle", "//div[contains(concat(' ',normalize-space(@class),' '),' %s ')]"),
95 DETAIL_HEADER("w-sdc-designer-sidebar-head", "//div[@data-tests-id='%s']"),
96 DETAIL_COMPONENT_NAME_DIV("selectedCompTitle", "//div[@data-tests-id='%s']"),
97 TAB_LIST("sdc-tabs-list", "//ul[@class='%s']/li"),
98 INFORMATION_TAB("detail-tab-information", "//li[@data-tests-id='%s']"),
99 INPUTS_TAB("detail-tab-inputs", "//li[@data-tests-id='%s']"),
100 DEPLOYMENT_ARTIFACTS_TAB("detail-tab-deployment-artifacts", "//li[@data-tests-id='%s']"),
101 INFORMATION_ARTIFACTS_TAB("detail-tab-information-artifacts", "//li[@data-tests-id='%s']"),
102 REQUIREMENTS_CAPABILITIES_TAB("detail-tab-requirements-capabilities", "//li[@data-tests-id='%s']"),
103 API_ARTIFACTS_TAB("detail-tab-api-artifacts", "//li[@data-tests-id='%s']"),
104 INTERFACE_OPERATIONS_TAB("detail-tab-interface-operations", "//li[@data-tests-id='%s']"),
105 SUBSTITUTION_FILTER_TAB("detail-tab-substitution-filter", "//li[@data-tests-id='%s']");
108 private final String id;
109 private final String xpathFormat;
111 public String getXpath() {
112 return String.format(xpathFormat, id);
118 public enum CompositionDetailTabName {
119 INFORMATION(XpathSelector.INFORMATION_TAB),
120 INPUTS(XpathSelector.INPUTS_TAB),
121 DEPLOYMENT_ARTIFACTS(XpathSelector.DEPLOYMENT_ARTIFACTS_TAB),
122 INFORMATIONAL_ARTIFACTS(XpathSelector.INFORMATION_ARTIFACTS_TAB),
123 API_ARTIFACTS(XpathSelector.API_ARTIFACTS_TAB),
124 SUBSTITUTION_FILTER(XpathSelector.SUBSTITUTION_FILTER_TAB),
125 INTERFACE_OPERATIONS(XpathSelector.INTERFACE_OPERATIONS_TAB),
126 REQUIREMENTS_CAPABILITIES(XpathSelector.REQUIREMENTS_CAPABILITIES_TAB);
128 private final XpathSelector xpathSelector;