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;
23 import java.util.ArrayList;
24 import java.util.List;
25 import lombok.AllArgsConstructor;
27 import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject;
28 import org.openqa.selenium.By;
29 import org.openqa.selenium.WebDriver;
30 import org.openqa.selenium.WebElement;
32 public class ToscaArtifactsPage extends AbstractPageObject {
34 private final List<String> downloadedArtifactList = new ArrayList<>();
35 private WebElement wrappingElement;
36 private WebElement artifactsTableBody;
38 public ToscaArtifactsPage(final WebDriver webDriver) {
43 public void isLoaded() {
44 wrappingElement = waitForElementVisibility(By.xpath(XpathSelector.MAIN_DIV.getXpath()), 5);
45 waitForElementVisibility(By.xpath(XpathSelector.TITLE_DIV.getXpath()), 5);
46 artifactsTableBody = waitForElementVisibility(By.xpath(XpathSelector.DATA_TABLE_BODY.getXpath()), 5);
49 public void clickOnDownload(final String artifactName) {
50 artifactsTableBody.findElement(By.xpath(XpathSelector.DOWNLOAD_LINK.getXpath(artifactName))).click();
53 public void addToDownloadedArtifactList(final String downloadedArtifactName) {
54 if (downloadedArtifactName == null) {
57 downloadedArtifactList.add(downloadedArtifactName);
60 public List<String> getDownloadedArtifactList() {
61 return new ArrayList<>(downloadedArtifactList);
65 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
68 private enum XpathSelector {
69 MAIN_DIV("w-sdc-main-right-container", "//div[@class='%s']"),
70 TITLE_DIV("tab-title", "//div[contains(@class,'%s') and contains(text(), 'TOSCA Artifacts')]"),
71 DATA_TABLE_BODY("//datatable-body"),
72 DOWNLOAD_LINK("//div[contains(@data-tests-id,'download_%s')]");
76 private final String xpathFormat;
78 XpathSelector(final String xpathFormat) {
79 this.xpathFormat = xpathFormat;
82 public String getXpath() {
83 return String.format(xpathFormat, id);
86 public String getXpath(final String... params) {
87 return String.format(xpathFormat, params);