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.openecomp.sdc.ci.tests.pages;
22 import org.openqa.selenium.By;
23 import org.openqa.selenium.WebDriver;
24 import org.openqa.selenium.WebElement;
25 import org.openqa.selenium.support.ui.ExpectedConditions;
27 import java.util.ArrayList;
28 import java.util.List;
30 import static org.openecomp.sdc.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.MAIN_DIV;
31 import static org.openecomp.sdc.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.NO_DATA_MESSAGE;
32 import static org.openecomp.sdc.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.PROPERTIES_TABLE;
33 import static org.openecomp.sdc.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.SOFTWARE_VERSION_INPUT;
34 import static org.openecomp.sdc.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.SOFTWARE_VERSION_PROPERTY_CHECKBOX;
35 import static org.openecomp.sdc.ci.tests.pages.ResourcePropertiesAssignmentPage.XpathSelector.TITLE_DIV;
38 * Handles the Resource Properties Assignment Page UI actions
40 public class ResourcePropertiesAssignmentPage extends AbstractPageObject {
42 private WebElement wrappingElement;
44 public ResourcePropertiesAssignmentPage(final WebDriver webDriver) {
49 public void isLoaded() {
50 wrappingElement = getWait(5)
51 .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(MAIN_DIV.getXpath())));
53 .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(TITLE_DIV.getXpath())));
57 * Gets the software_version property values.
59 * @return the list of software versions found
61 public List<String> getSoftwareVersionProperty() {
62 waitPropertiesToLoad();
63 final By swVersionCheckboxLocator = By.xpath(SOFTWARE_VERSION_PROPERTY_CHECKBOX.getXpath());
64 getWait(5).until(ExpectedConditions.visibilityOfElementLocated(swVersionCheckboxLocator));
66 final List<String> softwareVersionList = new ArrayList<>();
67 final List<WebElement> elements = wrappingElement.findElements(By.xpath(SOFTWARE_VERSION_INPUT.getXpath()));
68 for (final WebElement element : elements) {
69 softwareVersionList.add(element.getAttribute("value"));
72 return softwareVersionList;
76 * Waits for the properties loading.
78 private void waitPropertiesToLoad() {
80 .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(PROPERTIES_TABLE.getXpath())));
82 .until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(NO_DATA_MESSAGE.getXpath())));
86 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
88 public enum XpathSelector {
89 MAIN_DIV("w-sdc-main-right-container", "//div[@class='%s']"),
90 TITLE_DIV("tab-title", "//div[contains(@class,'%s') and contains(text(), 'Properties Assignment')]"),
91 PROPERTIES_TABLE("properties-table", "//div[contains(@class,'%s')]"),
92 NO_DATA_MESSAGE("no-data", "//div[contains(@class,'%s') and text()='No data to display']"),
93 SOFTWARE_VERSION_PROPERTY_CHECKBOX("software_versions", "//checkbox[@data-tests-id='%s']"),
94 SOFTWARE_VERSION_INPUT("value-prop-software_versions.", "//input[starts-with(@data-tests-id,'%s')]");
96 private final String id;
97 private final String xpathFormat;
99 XpathSelector(final String id, final String xpathFormat) {
101 this.xpathFormat = xpathFormat;
104 public String getId() {
108 public String getXpath() {
109 return String.format(xpathFormat, id);