2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 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.openecomp.sdc.ci.tests.pages;
22 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
23 import org.openqa.selenium.By;
24 import org.openqa.selenium.WebDriver;
25 import org.openqa.selenium.WebElement;
26 import org.openqa.selenium.support.ui.ExpectedConditions;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 import static org.openecomp.sdc.ci.tests.pages.VspCommitModal.XpathSelector.COMMIT_AND_SUBMIT_BTN;
31 import static org.openecomp.sdc.ci.tests.pages.VspCommitModal.XpathSelector.COMMIT_COMMENT_TXT;
32 import static org.openecomp.sdc.ci.tests.pages.VspCommitModal.XpathSelector.MODAL_CANCEL_BTN;
33 import static org.openecomp.sdc.ci.tests.pages.VspCommitModal.XpathSelector.MODAL_DIV;
34 import static org.openecomp.sdc.ci.tests.pages.VspCommitModal.XpathSelector.SUCCESS_MODAL_DIV;
37 * Handles the VSP Commit Modal UI actions
39 public class VspCommitModal extends AbstractPageObject {
41 private static final Logger LOGGER = LoggerFactory.getLogger(VspCommitModal.class);
43 private WebElement wrappingElement;
45 public VspCommitModal(final WebDriver webDriver) {
49 public void isLoaded() {
50 LOGGER.debug("Finding element with xpath '{}'", MODAL_DIV.getXpath());
51 wrappingElement = waitForElementVisibility(MODAL_DIV.getXpath());
55 * Fills the comment text area with a default message.
57 public void fillCommentWithDefaulMessage() {
58 final WebElement commentTxt = wrappingElement.findElement(By.xpath(COMMIT_COMMENT_TXT.getXpath()));
59 commentTxt.sendKeys("First VSP version");
63 * Clicks on the modal submit and confirms success.
65 public void submit() {
66 final WebElement commitAndSubmitBtn = wrappingElement.findElement(By.xpath(COMMIT_AND_SUBMIT_BTN.getXpath()));
67 commitAndSubmitBtn.click();
68 GeneralUIUtils.ultimateWait();
73 * Confirms the success of the modal submission.
75 private void confirmSuccess() {
76 final WebElement successModal = getWait()
77 .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(SUCCESS_MODAL_DIV.getXpath())));
78 successModal.findElement(By.xpath(MODAL_CANCEL_BTN.getXpath())).click();
82 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
84 public enum XpathSelector {
85 MODAL_DIV("sdc-modal-type-custom", "//div[contains(@class, '%s')]"),
86 COMMIT_AND_SUBMIT_BTN("form-submit-button", "//button[@data-test-id='%s']"),
87 COMMIT_COMMENT_TXT("commit-comment-text", "//textarea[@data-test-id='%s']"),
88 SUCCESS_MODAL_DIV("sdc-modal-type-info", "//div[contains(@class, '%s')]"),
89 MODAL_CANCEL_BTN("sdc-modal-cancel-button", "//button[@data-test-id='%s']");
91 private final String id;
92 private final String xpath;
94 XpathSelector(final String id, final String xpath) {
99 public String getId() {
103 public String getXpath() {
104 return String.format(xpath, id);