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 java.util.HashMap;
23 import java.util.List;
26 import org.openqa.selenium.By;
27 import org.openqa.selenium.WebDriver;
28 import org.openqa.selenium.WebElement;
30 import lombok.AllArgsConstructor;
34 * Handles the Resource Properties Page UI actions
36 public class ResourcePropertiesPage extends AbstractPageObject {
38 public ResourcePropertiesPage(final WebDriver webDriver) {
43 public void isLoaded() {
44 waitForElementVisibility(By.xpath(XpathSelector.TITLE_DIV.getXpath()));
45 waitPropertiesToLoad();
49 * Waits for the properties table to load.
51 private void waitPropertiesToLoad() {
52 waitForElementVisibility(By.xpath(XpathSelector.PROPERTIES_TABLE.getXpath()));
53 waitForElementInvisibility(By.xpath(XpathSelector.NO_DATA_MESSAGE.getXpath()));
57 * Creates a map based on property names and data types
59 public Map<String, String> getPropertyNamesAndTypes() {
60 waitPropertiesToLoad();
61 final Map<String, String> namesAndTypes = new HashMap<>();
62 final List<WebElement> names = findElements(By.xpath(XpathSelector.PROPERTY_NAMES.getXpath()));
63 final List<WebElement> types = findElements(By.xpath(XpathSelector.PROPERTY_TYPES.getXpath()));
65 for (int i = 0;i < names.size();i++) {
66 namesAndTypes.put(names.get(i).getAttribute("innerText"), types.get(i).getAttribute("innerText"));
74 private enum XpathSelector {
75 TITLE_DIV("//div[contains(@class,'tab-title') and contains(text(), 'Properties')]"),
76 PROPERTIES_TABLE("//div[contains(@class,'table')]"),
77 NO_DATA_MESSAGE("//div[contains(@class,'no-data') and text()='No data to display']"),
78 PROPERTY_TYPES("//*[contains(@data-tests-id, 'propertyType')]"),
79 PROPERTY_NAMES("//*[contains(@data-tests-id, 'propertyName')]");
81 private final String xpath;