2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.sdc.frontend.ci.tests.pages;
23 import com.aventstack.extentreports.Status;
24 import org.onap.sdc.frontend.ci.tests.datatypes.DataTestIdEnum;
25 import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest;
26 import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils;
27 import org.openqa.selenium.By;
28 import org.openqa.selenium.WebElement;
29 import org.openqa.selenium.support.ui.Select;
33 public class UploadArtifactPopup {
35 private static final int WAITING_FOR_ELEMENT_TIME_OUT = 10;
36 private boolean isCompositionPage;
38 public UploadArtifactPopup(boolean isCompositionPage) {
40 this.isCompositionPage = isCompositionPage;
43 public UploadArtifactPopup() {
47 private WebElement getArtifactDescriptionWebElement() {
48 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_DESCRIPTION.getValue());
51 public void loadFile(String path, String filename) {
52 final WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPopup.BROWSE.getValue());
53 browseWebElement.sendKeys(path + File.separator + filename);
54 GeneralUIUtils.ultimateWait();
57 public void loadUndefinedFile(String path, String filename) {
58 final WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPopup.FILE_UNDEFINED.getValue());
59 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Uploading file: %s", path + File.separator + filename));
60 browseWebElement.sendKeys(path + File.separator + filename);
61 GeneralUIUtils.ultimateWait();
65 public void insertDescription(String artifactDescriptoin) {
66 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Changing artifact description to: %s", artifactDescriptoin));
67 WebElement artifactDescriptionTextbox = getArtifactDescriptionWebElement();
68 artifactDescriptionTextbox.clear();
69 artifactDescriptionTextbox.sendKeys(artifactDescriptoin);
71 GeneralUIUtils.ultimateWait();
74 public Select defineArtifactLabel(String requiredArtifactLabel) {
75 Select selectList = null;
76 WebElement artifactLabelWebElement;
78 artifactLabelWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue());
81 artifactLabelWebElement.clear();
82 artifactLabelWebElement.sendKeys(requiredArtifactLabel);
86 public void selectArtifactType(String artifactType) {
87 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPopup.ARTIFACT_TYPE_ICON.getValue());
88 GeneralUIUtils.clickOnElementByTestId(artifactType);
91 public void clickDoneButton() throws Exception {
92 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPopup.DONE_BUTTON.getValue());
93 GeneralUIUtils.waitForLoader();
94 GeneralUIUtils.waitForElementInVisibilityBy(By.className("sdc-add-artifact"), WAITING_FOR_ELEMENT_TIME_OUT);
97 public void clickUpgradeArtifactsButton() throws Exception {
98 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPGRADE_ARTIFACT_BUTTON.getValue());
99 GeneralUIUtils.waitForLoader();
100 GeneralUIUtils.waitForElementInVisibilityBy(By.className("sdc-add-artifact"), WAITING_FOR_ELEMENT_TIME_OUT);
103 public void clickCancelButton() throws Exception {
104 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.CANCEL_BUTTON.getValue()).click();
105 GeneralUIUtils.waitForLoader();
106 GeneralUIUtils.waitForElementInVisibilityByTestId("sdc-add-artifact");
109 // public void clickUpdateButton() throws Exception {
111 // GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.UPDATE_BUTTON.getValue()).click();
112 // GeneralUIUtils.waitForLoader();
113 // GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("sdc-add-artifact"), 50);
116 public void insertURL(String artifactDescriptoin) throws Exception {
117 WebElement artifactDescriptionTextbox = getArtifactURLWebElement();
118 artifactDescriptionTextbox.clear();
119 artifactDescriptionTextbox.sendKeys(artifactDescriptoin);
122 public WebElement getArtifactURLWebElement() {
123 return GeneralUIUtils.getWebElementBy(By.cssSelector((DataTestIdEnum.ArtifactPopup.URL.getValue())));