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 / VlmSubmitModal.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 VLM Submit Modal UI actions
32  */
33 public class VlmSubmitModal extends AbstractPageObject {
34
35     private static final Logger LOGGER = LoggerFactory.getLogger(VlmSubmitModal.class);
36
37
38     public VlmSubmitModal(final WebDriver webDriver) {
39         super(webDriver);
40     }
41
42     public void isLoaded() {
43         LOGGER.debug("Finding element with xpath '{}'", XpathSelector.MODAL_DIV.getXpath());
44         waitForElementVisibility(XpathSelector.MODAL_DIV.getXpath());
45     }
46
47     /**
48      * Confirms the success of the modal submission.
49      */
50     public void confirmSuccess() {
51         final WebElement successModal = waitForElementVisibility(XpathSelector.SUCCESS_MODAL_DIV.getXpath());
52         successModal.findElement(By.xpath(XpathSelector.MODAL_CANCEL_BTN.getXpath())).click();
53     }
54
55     /**
56      * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
57      */
58     @AllArgsConstructor
59     private enum XpathSelector {
60         MODAL_DIV("sdc-modal", "//div[contains(@class, '%s')]"),
61         SUBMIT_BTN("vc-submit-btn", "//div[@data-test-id='%s']"),
62         SUCCESS_MODAL_DIV("sdc-modal-type-info", "//div[contains(@class, '%s')]"),
63         MODAL_CANCEL_BTN("sdc-modal-cancel-button", "//button[@data-test-id='%s']");
64
65         @Getter
66         private final String id;
67         private final String xpath;
68
69         public String getXpath() {
70             return String.format(xpath, id);
71         }
72     }
73
74 }