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
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.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
20 package org.onap.sdc.frontend.ci.tests.pages;
22 import lombok.AllArgsConstructor;
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;
31 * Handles the Commit Modal UI action when certifying a component
33 public class ComponentCertificationModal extends AbstractPageObject {
35 private static final Logger LOGGER = LoggerFactory.getLogger(ComponentCertificationModal.class);
37 private WebElement wrappingElement;
39 public ComponentCertificationModal(final WebDriver webDriver) {
43 public void isLoaded() {
44 LOGGER.debug("Finding element with xpath '{}'", XpathSelector.MODAL_DIV.getXpath());
45 wrappingElement = waitForElementVisibility(XpathSelector.MODAL_DIV.getXpath());
49 * Fills commit text area with a default message.
51 public void fillCommentWithDefaultMessage() {
52 final WebElement commentTxt = wrappingElement.findElement(By.xpath(XpathSelector.COMMIT_COMMENT_TXT.getXpath()));
53 commentTxt.sendKeys("UI Integration Test");
57 * Clicks on the modal submit and confirms success.
59 public void submit() {
60 final WebElement commitAndSubmitBtn = wrappingElement.findElement(By.xpath(XpathSelector.MODAL_OK_BTN.getXpath()));
61 commitAndSubmitBtn.click();
65 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
68 private enum XpathSelector {
69 MODAL_DIV("sdc-modal-type-custom", "//div[contains(@class, '%s')]"),
70 COMMIT_COMMENT_TXT("checkindialog", "//textarea[@data-tests-id='%s']"),
71 MODAL_OK_BTN("confirm-modal-button-ok", "//button[@data-tests-id='%s']"),
72 MODAL_CANCEL_BTN("confirm-modal-button-cancel", "//button[@data-tests-id='%s']");
75 private final String id;
76 private final String xpath;
78 public String getXpath() {
79 return String.format(xpath, id);