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.openecomp.sdc.ci.tests.pages;
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;
33 import com.aventstack.extentreports.Status;
35 public class UploadArtifactPopup {
37 boolean isCompositionPage;
39 public UploadArtifactPopup(boolean isCompositionPage) {
41 this.isCompositionPage = isCompositionPage;
44 public UploadArtifactPopup() {
48 public WebElement getArtifactDescriptionWebElement(){
49 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_DESCRIPTION.getValue());
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();
58 // if (!browseWebElement.getAttribute("value").equals(filename))
60 // throw new TestException("File named " + filename + " does not presented");
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);
72 GeneralUIUtils.ultimateWait();;
75 public Select defineArtifactLabel(String requiredArtifactLabel) {
76 Select selectList = null;
77 WebElement artifactLabelWebElement = null;
79 // if (isCompositionPage){
80 artifactLabelWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue());
83 // selectList = GeneralUIUtils.getSelectList("Create New Artifact", DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue());
84 // artifactLabelWebElement = GeneralUIUtils.getDriver().findElement(By.name(DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue()));
87 artifactLabelWebElement.clear();
88 artifactLabelWebElement.sendKeys(requiredArtifactLabel);
92 public Select selectArtifactType(String artifactType) {
93 return GeneralUIUtils.getSelectList(artifactType, DataTestIdEnum.ArtifactPopup.ARTIFACT_TYPE.getValue());
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);
102 public void clickCancelButton() throws Exception {
103 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.CANCEL_BUTTON.getValue()).click();
104 GeneralUIUtils.waitForLoader();
105 GeneralUIUtils.waitForElementInVisibilityByTestId("sdc-add-artifact");
108 // public void clickUpdateButton() throws Exception {
110 // GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.UPDATE_BUTTON.getValue()).click();
111 // GeneralUIUtils.waitForLoader();
112 // GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("sdc-add-artifact"), 50);
115 public void insertURL(String artifactDescriptoin) throws Exception {
116 WebElement artifactDescriptionTextbox = getArtifactURLWebElement();
117 artifactDescriptionTextbox.clear();
118 artifactDescriptionTextbox. sendKeys(artifactDescriptoin);
121 public WebElement getArtifactURLWebElement(){
122 return GeneralUIUtils.getWebElementBy(By.cssSelector((DataTestIdEnum.ArtifactPopup.URL.getValue())));