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