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.component.workspace;
22 import com.aventstack.extentreports.Status;
23 import lombok.AllArgsConstructor;
25 import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
26 import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject;
27 import org.openqa.selenium.By;
28 import org.openqa.selenium.WebDriver;
29 import org.openqa.selenium.WebElement;
32 * Represents the Composition Interface Operations Modal.
34 public class CompositionInterfaceOperationsModal extends AbstractPageObject {
36 public CompositionInterfaceOperationsModal(final WebDriver webDriver) {
41 public void isLoaded() {
42 waitForElementVisibility(By.xpath(XpathSelector.TITLE_SPAN.getXPath()));
43 waitForElementVisibility(By.xpath(XpathSelector.INTERFACE_NAME_LABEL.getXPath()));
44 waitForElementVisibility(By.xpath(XpathSelector.OPERATION_NAME_LABEL.getXPath()));
45 waitForElementVisibility(By.xpath(XpathSelector.INPUT_NAME_SPAN.getXPath()));
46 waitForElementVisibility(By.xpath(XpathSelector.INPUT_VALUE_SPAN.getXPath()));
48 waitToBeClickable(By.xpath(XpathSelector.ADD_INPUT_BTN.getXPath()));
49 waitToBeClickable(By.xpath(XpathSelector.SAVE_BTN.getXPath()));
50 waitToBeClickable(By.xpath(XpathSelector.CANCEL_BTN.getXPath()));
53 public void clickOnSave() {
54 waitToBeClickable(By.xpath(XpathSelector.SAVE_BTN.getXPath())).click();
57 public void clickOnCancel() {
58 waitToBeClickable(By.xpath(XpathSelector.CANCEL_BTN.getXPath())).click();
61 public void clickOnDelete() {
62 waitToBeClickable(By.xpath(XpathSelector.DELETE_BTN.getXPath())).click();
65 public void updateInterfaceOperation(final InterfaceOperationsData interfaceOperationsData) {
66 fillDescription(interfaceOperationsData.getDescription());
67 fillImplementationName(interfaceOperationsData.getImplementationName());
68 fillInputName(interfaceOperationsData.getInputName());
69 fillInputValue(interfaceOperationsData.getInputValue());
73 private void fillDescription(final String description) {
74 setInputField(By.xpath(XpathSelector.INTERFACE_OPERATION_DESCRIPTION_INPUT.getXPath()), description);
77 private void fillImplementationName(final String implementationName) {
78 setInputField(By.xpath(XpathSelector.INTERFACE_OPERATION_IMPLEMENTATION_NAME_INPUT.getXPath()), implementationName);
81 private void fillInputName(final String inputName) {
82 setInputField(By.xpath(XpathSelector.FIELD_INPUT_NAME_INPUT.getXPath()), inputName);
85 private void fillInputValue(final String inputValue) {
86 setInputField(By.xpath(XpathSelector.FIELD_INPUT_VALUE_INPUT.getXPath()), inputValue);
89 private void setInputField(final By locator, final String value) {
93 final WebElement webElement = findElement(locator);
95 webElement.sendKeys(value);
96 ExtentTestActions.takeScreenshot(Status.INFO, value, value);
99 public void addInput() {
100 waitToBeClickable(By.xpath(XpathSelector.ADD_INPUT_BTN.getXPath())).click();
103 public String getDescription() {
104 return findElement(By.xpath(XpathSelector.INTERFACE_OPERATION_DESCRIPTION_INPUT.getXPath())).getAttribute("value");
107 public String getImplementationName() {
108 return findElement(By.xpath(XpathSelector.INTERFACE_OPERATION_IMPLEMENTATION_NAME_INPUT.getXPath())).getAttribute("value");
111 public String getInputName() {
112 return findElement(By.xpath(XpathSelector.FIELD_INPUT_NAME_INPUT.getXPath())).getAttribute("value");
115 public String getInputValue() {
116 return findElement(By.xpath(XpathSelector.FIELD_INPUT_VALUE_INPUT.getXPath())).getAttribute("value");
121 public static class InterfaceOperationsData {
123 private final String description;
124 private final String implementationName;
125 private final String inputName;
126 private final String inputValue;
130 private enum XpathSelector {
131 TITLE_SPAN("//span[@class='title' and contains(text(), 'Edit Operation')]"),
132 ADD_INPUT_BTN("//a[contains(@class,'add-param-link add-btn') and contains(text(), 'Add Input')]"),
133 DELETE_BTN("//svg-icon[@name='trash-o']"),
134 SAVE_BTN("//button[@data-tests-id='Save']"),
135 CANCEL_BTN("//button[@data-tests-id='Cancel']"),
136 INTERFACE_NAME_LABEL("//label[contains(@class,'sdc-input') and contains(text(), 'Interface Name')]"),
137 OPERATION_NAME_LABEL("//label[contains(@class,'sdc-input') and contains(text(), 'Operation Name')]"),
138 INTERFACE_OPERATION_DESCRIPTION_INPUT("//input[@data-tests-id='interface-operation-description']"),
139 INTERFACE_OPERATION_IMPLEMENTATION_NAME_INPUT("//input[@data-tests-id='interface-operation-implementation-name']"),
140 INPUT_NAME_SPAN("//span[contains(@class,'field-input-name') and contains(text(), 'Name')]"),
141 INPUT_VALUE_SPAN("//span[contains(@class,'field-input-value') and contains(text(), 'Value')]"),
142 FIELD_INPUT_NAME_INPUT("//input[@data-tests-id='interface-operation-input-name']"),
143 FIELD_INPUT_VALUE_INPUT("//input[@data-tests-id='interface-operation-input-value']");
146 private final String xPath;