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;
22 import static org.junit.jupiter.api.Assertions.assertTrue;
24 import com.aventstack.extentreports.Status;
25 import lombok.AllArgsConstructor;
27 import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
28 import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionHierarchyComponent;
29 import org.openqa.selenium.By;
30 import org.openqa.selenium.WebDriver;
33 * Handles the 'Attributes & Outputs' Page UI actions
35 public class AttributesOutputsPage extends ComponentPage {
37 private final AttributesTabComponent attributesTabComponent;
38 private final OutputsTabComponent outputsTabComponent;
39 private final CompositionHierarchyComponent compositionHierarchyComponent;
41 public AttributesOutputsPage(final WebDriver webDriver) {
43 attributesTabComponent = new AttributesTabComponent(webDriver);
44 outputsTabComponent = new OutputsTabComponent(webDriver);
45 compositionHierarchyComponent = new CompositionHierarchyComponent(webDriver);
50 public void isLoaded() {
52 waitForElementVisibility(By.xpath(XpathSelector.MAIN_DIV.getXpath()));
53 waitForElementVisibility(By.xpath(XpathSelector.TITLE_DIV.getXpath()));
54 attributesTabComponent.isLoaded();
55 compositionHierarchyComponent.isLoaded();
58 public void clickOnAttributeNavigation(final String id) {
59 compositionHierarchyComponent.clickOnAttributeNavigation(id);
60 assertTrue(attributesTabComponent.isInstanceSelected(id));
64 * Checks if a attribute exists.
66 * @return true if exists, false if not
68 public boolean isAttributePresent(final String attributeName) {
69 ExtentTestActions.log(Status.INFO, "Going to check if Attribute '" + attributeName + "' is present");
70 return attributesTabComponent.isAttributePresent(attributeName);
74 * Checks if a output exists.
76 * @return true if exists, false if not
78 public boolean isOutputPresent(final String outputName) {
79 ExtentTestActions.log(Status.INFO, "Going to check if Output '" + outputName + "' is present");
80 return outputsTabComponent.isOutputPresent(outputName);
84 * Checks if a output deleted.
86 * @return true if deleted, false if not
88 public boolean isOutputDeleted(final String outputName) {
89 ExtentTestActions.log(Status.INFO, "Going to check if Output '" + outputName + "' deleted");
90 return outputsTabComponent.isOutputDeleted(outputName);
93 public void declareOutput(final String attributeName) {
94 ExtentTestActions.log(Status.INFO, "Going to declare Attribute '" + attributeName + "' as Output");
95 attributesTabComponent.declareOutput(attributeName);
98 public void deleteOutput(final String outputName) {
99 ExtentTestActions.log(Status.INFO, "Going to delete Output '" + outputName + "'");
100 outputsTabComponent.deleteOutput(outputName);
103 public void clickOnOutputsTab() {
104 waitForElementVisibility(By.xpath(XpathSelector.OUTPUTS_TAB.getXpath())).click();
105 outputsTabComponent.isLoaded();
108 public void clickOnAttributesTab() {
109 waitForElementVisibility(By.xpath(XpathSelector.ATTRIBUTES_TAB.getXpath())).click();
110 attributesTabComponent.isLoaded();
114 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
117 private enum XpathSelector {
118 MAIN_DIV("w-sdc-main-right-container", "//div[@class='%s']"),
119 TITLE_DIV("tab-title", "//div[contains(@class,'%s') and contains(text(), 'Attributes & Outputs')]"),
120 ATTRIBUTES_TAB("Attributes", "//*[@data-tests-id='%s']"),
121 OUTPUTS_TAB("Outputs", "//*[@data-tests-id='%s']");
124 private final String id;
125 private final String xpathFormat;
127 public String getXpath() {
128 return String.format(xpathFormat, id);