Improve ETSI NS UI test
[sdc.git] / integration-tests / src / test / java / org / onap / sdc / frontend / ci / tests / pages / component / workspace / RelationshipWizardComponent.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.component.workspace;
21
22 import lombok.AllArgsConstructor;
23 import lombok.Getter;
24 import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject;
25 import org.openqa.selenium.WebDriver;
26
27 /**
28  * Represents the relationship wizard dialog that is used when creating a relationship between two nodes in the composition screen.
29  */
30 public class RelationshipWizardComponent extends AbstractPageObject {
31
32     public RelationshipWizardComponent(final WebDriver webDriver) {
33         super(webDriver);
34     }
35
36     @Override
37     public void isLoaded() {
38         waitForElementVisibility(XpathSelector.WIZARD.getXpath());
39         waitForElementVisibility(XpathSelector.CANCEL_BUTTON.getXpath());
40         waitForElementVisibility(XpathSelector.NEXT_BUTTON.getXpath());
41     }
42
43     public void clickOnNext() {
44         waitToBeClickable(XpathSelector.NEXT_BUTTON.getXpath()).click();
45     }
46
47     public void clickOnBack() {
48         waitToBeClickable(XpathSelector.BACK_BUTTON.getXpath()).click();
49     }
50
51     public void clickOnCancel() {
52         waitToBeClickable(XpathSelector.CANCEL_BUTTON.getXpath()).click();
53     }
54
55     public void clickOnFinish() {
56         waitToBeClickable(XpathSelector.FINISH_BUTTON.getXpath()).click();
57     }
58
59     /**
60      * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
61      */
62     @AllArgsConstructor
63     private enum XpathSelector {
64         WIZARD("//multi-steps-wizard"),
65         WIZARD_FOOTER("//multi-steps-wizard//div[@class='ng2-modal-footer']"),
66         CANCEL_BUTTON(WIZARD_FOOTER.getXpath() + "//button[text()='Cancel']"),
67         NEXT_BUTTON(WIZARD_FOOTER.getXpath() + "//div[contains(@class, 'white-arrow-next')]/.."),
68         BACK_BUTTON(WIZARD_FOOTER.getXpath() + "//div[contains(@class, 'blue-arrow-back')]/.."),
69         FINISH_BUTTON(WIZARD_FOOTER.getXpath() + "//button[contains(text(), 'Finish')]");
70
71         @Getter
72         private final String xpath;
73     }
74 }