re base code
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / 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.openecomp.sdc.ci.tests.pages;
22
23 import com.aventstack.extentreports.Status;
24 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
25 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
26 import org.openecomp.sdc.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         boolean isCompositionPage;
36         
37         public UploadArtifactPopup(boolean isCompositionPage) {
38                 super();
39                 this.isCompositionPage = isCompositionPage;
40         }
41         
42         public UploadArtifactPopup() {
43                 super();
44         }
45         
46         public WebElement getArtifactDescriptionWebElement(){
47                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_DESCRIPTION.getValue());
48         }
49
50         public void loadFile(String path, String filename) {
51                 final WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPopup.BROWSE.getValue());
52 //              browseWebElement.sendKeys(path + filename);
53                 browseWebElement.sendKeys(path + File.separator + filename);
54                 GeneralUIUtils.ultimateWait();
55                 
56 //              if (!browseWebElement.getAttribute("value").equals(filename))
57 //              {
58 //                      throw new TestException("File named " + filename + " does not presented");
59 //              }
60         }
61         
62
63
64         public void insertDescription(String artifactDescriptoin) {
65                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Changing artifact description to: %s", artifactDescriptoin));  
66                 WebElement artifactDescriptionTextbox = getArtifactDescriptionWebElement();
67                 artifactDescriptionTextbox.clear();
68                 artifactDescriptionTextbox.sendKeys(artifactDescriptoin);
69         
70                 GeneralUIUtils.ultimateWait();;
71         }
72
73         public Select defineArtifactLabel(String requiredArtifactLabel) {
74                 Select selectList = null;
75                 WebElement artifactLabelWebElement = null;
76                 
77 //              if (isCompositionPage){
78                         artifactLabelWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue());
79 //              }
80 //              else{
81 //                      selectList = GeneralUIUtils.getSelectList("Create New Artifact", DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue());
82 //                      artifactLabelWebElement = GeneralUIUtils.getDriver().findElement(By.name(DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue()));      
83 //              }
84                 
85                 artifactLabelWebElement.clear();
86                 artifactLabelWebElement.sendKeys(requiredArtifactLabel);
87                 return selectList;
88         }
89
90         public Select selectArtifactType(String artifactType) {
91                 return GeneralUIUtils.getSelectList(artifactType, DataTestIdEnum.ArtifactPopup.ARTIFACT_TYPE.getValue());
92         }
93
94         public void clickDoneButton() throws Exception {
95                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPopup.DONE_BUTTON.getValue());
96                 GeneralUIUtils.waitForLoader();
97                 GeneralUIUtils.waitForElementInVisibilityBy(By.className("sdc-add-artifact"), 10);
98         }
99
100         public void clickCancelButton() throws Exception {
101                 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.CANCEL_BUTTON.getValue()).click();
102                 GeneralUIUtils.waitForLoader();
103                 GeneralUIUtils.waitForElementInVisibilityByTestId("sdc-add-artifact");
104         }
105
106 //      public void clickUpdateButton() throws Exception {
107 //              clickAddButton();
108 //              GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.UPDATE_BUTTON.getValue()).click();
109 //              GeneralUIUtils.waitForLoader();
110 //              GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("sdc-add-artifact"), 50);
111 //      }
112         
113         public void insertURL(String artifactDescriptoin) throws Exception {
114                 WebElement artifactDescriptionTextbox = getArtifactURLWebElement();
115                 artifactDescriptionTextbox.clear();
116                 artifactDescriptionTextbox. sendKeys(artifactDescriptoin);              
117         }
118         
119         public WebElement getArtifactURLWebElement(){
120                 return GeneralUIUtils.getWebElementBy(By.cssSelector((DataTestIdEnum.ArtifactPopup.URL.getValue())));
121         }
122         
123
124 }