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 / ComponentCertificationModal.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 Nordix Foundation
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  *
16  *  SPDX-License-Identifier: Apache-2.0
17  *  ============LICENSE_END=========================================================
18  */
19
20 package org.onap.sdc.frontend.ci.tests.pages;
21
22 import lombok.AllArgsConstructor;
23 import lombok.Getter;
24 import org.openqa.selenium.By;
25 import org.openqa.selenium.WebDriver;
26 import org.openqa.selenium.WebElement;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 /**
31  * Handles the Commit Modal UI action when certifying a component
32  */
33 public class ComponentCertificationModal extends AbstractPageObject {
34
35     private static final Logger LOGGER = LoggerFactory.getLogger(ComponentCertificationModal.class);
36
37     private WebElement wrappingElement;
38
39     public ComponentCertificationModal(final WebDriver webDriver) {
40         super(webDriver);
41     }
42
43     public void isLoaded() {
44         LOGGER.debug("Finding element with xpath '{}'", XpathSelector.MAIN_MODAL_DIV.getXpath());
45         waitForElementVisibility(XpathSelector.COMMIT_COMMENT_TXT.getXpath());
46         waitToBeClickable(XpathSelector.CANCEL_BUTTON.getXpath());
47         wrappingElement = waitForElementVisibility(XpathSelector.MAIN_MODAL_DIV.getXpath());
48     }
49
50     /**
51      * Fills commit text area with given message.
52      *
53      * @param comment the comment message
54      */
55     public void fillComment(final String comment) {
56         final WebElement commentTxt = wrappingElement.findElement(By.xpath(XpathSelector.COMMIT_COMMENT_TXT.getXpath()));
57         commentTxt.sendKeys(comment);
58     }
59
60     /**
61      * Click on the Ok button, submitting the certification.
62      */
63     public void clickOnOkButton() {
64         wrappingElement.findElement(By.xpath(XpathSelector.OK_BUTTON.getXpath())).click();
65     }
66
67     /**
68      * Click on the "x" to close the dialog.
69      */
70     public void clickOnCloseButton() {
71         wrappingElement.findElement(By.xpath(XpathSelector.CLOSE_X_BUTTON.getXpath())).click();
72     }
73
74     /**
75      * Click on the cancel button, closing the dialog.
76      */
77     public void clickOnCancelButton() {
78         wrappingElement.findElement(By.xpath(XpathSelector.CANCEL_BUTTON.getXpath())).click();
79     }
80
81     /**
82      * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
83      */
84     @AllArgsConstructor
85     private enum XpathSelector {
86         MAIN_MODAL_DIV("sdc-modal-type-custom", "//div[contains(@class, '%s')]"),
87         COMMIT_COMMENT_TXT("checkindialog", "//textarea[@data-tests-id='%s']"),
88         OK_BUTTON("confirm-modal-button-ok", "//button[@data-tests-id='%s']"),
89         CANCEL_BUTTON("confirm-modal-button-cancel", "//button[@data-tests-id='%s']"),
90         CLOSE_X_BUTTON("confirm-modal-close", "//button[@data-tests-id='%s']");
91
92         @Getter
93         private final String id;
94         private final String xpath;
95
96         public String getXpath() {
97             return String.format(xpath, id);
98         }
99     }
100
101 }