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.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage.XpathSelector.DATA_TABLE_BODY;
23 import static org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage.XpathSelector.DOWNLOAD_LINK;
24 import static org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage.XpathSelector.MAIN_DIV;
25 import static org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage.XpathSelector.TITLE_DIV;
27 import java.util.ArrayList;
28 import java.util.List;
29 import lombok.AllArgsConstructor;
31 import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject;
32 import org.openqa.selenium.By;
33 import org.openqa.selenium.WebDriver;
34 import org.openqa.selenium.WebElement;
36 public class ToscaArtifactsPage extends AbstractPageObject {
38 private WebElement wrappingElement;
39 private WebElement artifactsTableBody;
40 private final List<String> downloadedArtifactList = new ArrayList<>();
42 public ToscaArtifactsPage(final WebDriver webDriver) {
47 public void isLoaded() {
48 wrappingElement = waitForElementVisibility(By.xpath(MAIN_DIV.getXpath()), 5);
49 waitForElementVisibility(By.xpath(TITLE_DIV.getXpath()), 5);
50 artifactsTableBody = waitForElementVisibility(By.xpath(DATA_TABLE_BODY.getXpath()), 5);
53 public void clickOnDownload(final String artifactName) {
54 artifactsTableBody.findElement(By.xpath(DOWNLOAD_LINK.getXpath(artifactName))).click();
57 public void addToDownloadedArtifactList(final String downloadedArtifactName) {
58 if (downloadedArtifactName == null) {
61 downloadedArtifactList.add(downloadedArtifactName);
64 public List<String> getDownloadedArtifactList() {
65 return new ArrayList<>(downloadedArtifactList);
69 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
72 public enum XpathSelector {
73 MAIN_DIV("w-sdc-main-right-container", "//div[@class='%s']"),
74 TITLE_DIV("tab-title", "//div[contains(@class,'%s') and contains(text(), 'TOSCA Artifacts')]"),
75 DATA_TABLE_BODY("//datatable-body"),
76 DOWNLOAD_LINK("//div[contains(@data-tests-id,'download_%s')]");
81 private final String xpathFormat;
83 XpathSelector(final String xpathFormat) {
84 this.xpathFormat = xpathFormat;
87 public String getXpath() {
88 return String.format(xpathFormat, id);
91 public String getXpath(final String... params) {
92 return String.format(xpathFormat, params);