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 java.util.List;
25 import org.openqa.selenium.By;
26 import org.openqa.selenium.WebDriver;
28 import lombok.AllArgsConstructor;
32 * Handles the Resource Properties Assignment Page UI actions.
34 public class ResourcePropertiesAssignmentPage extends AbstractPageObject {
36 private ResourcePropertiesAssignmentTab resourcePropertiesAssignmentTab;
37 private ResourcePropertiesAssignmentInputTab resourcePropertiesAssignmentInputTab;
39 public ResourcePropertiesAssignmentPage(final WebDriver webDriver) {
41 resourcePropertiesAssignmentTab = new ResourcePropertiesAssignmentTab(webDriver);
42 resourcePropertiesAssignmentInputTab = new ResourcePropertiesAssignmentInputTab(webDriver);
46 public void isLoaded() {
47 waitForElementVisibility((By.xpath(XpathSelector.MAIN_DIV.getXpath())));
48 waitForElementVisibility(By.xpath(XpathSelector.TITLE_DIV.getXpath()));
49 resourcePropertiesAssignmentTab.isLoaded();
53 * Select the Properties Tab to be displayed
55 public void selectPropertiesTab() {
56 findElement(By.xpath(XpathSelector.PROPERTIES_TAB.getXpath())).click();
57 resourcePropertiesAssignmentTab.isLoaded();
61 * Select the Input Tab to be displayed
63 public void selectInputTab() {
64 findElement(By.xpath(XpathSelector.INPUT_TAB.getXpath())).click();
65 resourcePropertiesAssignmentInputTab.isLoaded();
68 public List<String> getSoftwareVersionProperty() {
69 return resourcePropertiesAssignmentTab.getSoftwareVersionProperty();
72 public void setPropertyValue(final String propertyName, final Object value) {
73 resourcePropertiesAssignmentTab.setPropertyValue(propertyName, value);
76 public boolean isPropertyPresent(final String propertyName) {
77 return resourcePropertiesAssignmentTab.isPropertyPresent(propertyName);
80 public void saveProperties() {
81 resourcePropertiesAssignmentTab.saveProperties();
84 public void addProperties(final Map<String, String> propertiesMap) {
85 resourcePropertiesAssignmentTab.addProperties(propertiesMap);
88 public Map<String, String> getPropertyNamesAndTypes() {
89 return resourcePropertiesAssignmentTab.getPropertyNamesAndTypes();
92 public void setInputPropertyMetadata(String name, String key, String value) {
93 resourcePropertiesAssignmentInputTab.setInputPropertyMetadata(name, key, value);
96 public List<String> getInputPropertyNames() {
97 return resourcePropertiesAssignmentInputTab.getInputPropertyNames();
101 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
104 private enum XpathSelector {
105 MAIN_DIV("w-sdc-main-right-container", "//div[@class='%s']"),
106 TITLE_DIV("tab-title", "//div[contains(@class,'%s') and contains(text(), 'Properties Assignment')]"),
107 PROPERTIES_TAB("//*[contains(@data-tests-id, 'Properties') and contains(@class, 'tab')]"),
108 INPUT_TAB("//*[contains(@data-tests-id, 'Inputs') and contains(@class, 'tab')]");
112 private final String xpathFormat;
114 XpathSelector(final String xpathFormat) {
115 this.xpathFormat = xpathFormat;
118 public String getXpath() {
119 return String.format(xpathFormat, id);