Provide user to specify the ouput name while declaring the atrributes
[sdc.git] / integration-tests / src / test / java / org / onap / sdc / frontend / ci / tests / pages / UploadArtifactPopup.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.sdc.frontend.ci.tests.pages;
22
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;
30
31 import java.io.File;
32
33 public class UploadArtifactPopup {
34
35     private static final int WAITING_FOR_ELEMENT_TIME_OUT = 10;
36     private boolean isCompositionPage;
37
38     public UploadArtifactPopup(boolean isCompositionPage) {
39         super();
40         this.isCompositionPage = isCompositionPage;
41     }
42
43     public UploadArtifactPopup() {
44         super();
45     }
46
47     private WebElement getArtifactDescriptionWebElement() {
48         return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_DESCRIPTION.getValue());
49     }
50
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();
55     }
56
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();
62     }
63
64
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);
70
71         GeneralUIUtils.ultimateWait();
72     }
73
74     public Select defineArtifactLabel(String requiredArtifactLabel) {
75         Select selectList = null;
76         WebElement artifactLabelWebElement;
77
78         artifactLabelWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue());
79
80
81         artifactLabelWebElement.clear();
82         artifactLabelWebElement.sendKeys(requiredArtifactLabel);
83         return selectList;
84     }
85
86     public void selectArtifactType(String artifactType) {
87         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPopup.ARTIFACT_TYPE_ICON.getValue());
88         GeneralUIUtils.clickOnElementByTestId(artifactType);
89     }
90
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);
95     }
96
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);
101     }
102
103     public void clickCancelButton() throws Exception {
104         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.CANCEL_BUTTON.getValue()).click();
105         GeneralUIUtils.waitForLoader();
106         GeneralUIUtils.waitForElementInVisibilityByTestId("sdc-add-artifact");
107     }
108
109 //      public void clickUpdateButton() throws Exception {
110 //              clickAddButton();
111 //              GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.UPDATE_BUTTON.getValue()).click();
112 //              GeneralUIUtils.waitForLoader();
113 //              GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("sdc-add-artifact"), 50);
114 //      }
115
116     public void insertURL(String artifactDescriptoin) throws Exception {
117         WebElement artifactDescriptionTextbox = getArtifactURLWebElement();
118         artifactDescriptionTextbox.clear();
119         artifactDescriptionTextbox.sendKeys(artifactDescriptoin);
120     }
121
122     public WebElement getArtifactURLWebElement() {
123         return GeneralUIUtils.getWebElementBy(By.cssSelector((DataTestIdEnum.ArtifactPopup.URL.getValue())));
124     }
125
126
127 }