2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.pages;
23 import java.util.List;
24 import java.util.function.Supplier;
26 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
27 import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
28 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
29 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
30 import org.openqa.selenium.By;
31 import org.openqa.selenium.WebElement;
33 import com.aventstack.extentreports.Status;
35 public class GeneralPageElements {
37 public GeneralPageElements() {
41 public static ResourceLeftMenu getLeftMenu() {
42 return new ResourceLeftMenu();
45 public static void clickOKButton() {
46 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the OK button");
47 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue());
48 GeneralUIUtils.waitForLoader();
51 public static void clickCreateButton() {
52 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the CREATE/UPDATE button.");
53 GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue());
54 GeneralUIUtils.ultimateWait();
55 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue());
56 ExtentTestActions.log(Status.INFO, "Succeeded.");
59 public static void clickCreateButton(int timeout) {
60 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the CREATE/UPDATE button");
61 GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue(), timeout);
62 GeneralUIUtils.ultimateWait();
63 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue());
66 public static void clickUpdateButton(){
70 public static void clickCheckinButton(String componentName) throws Exception {
71 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the CHECKIN button");
72 GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue());
73 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.ACCEP_TESTING_MESSAGE.getValue()).sendKeys("Checkin " + componentName);
74 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue());
75 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue(), 60);
76 GeneralUIUtils.ultimateWait();
79 public static void clickSubmitForTestingButton(String componentName) throws Exception {
80 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the submiting for testing button");
81 GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.SUBMIT_FOR_TESTING_BUTTON.getValue());
82 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.SUMBIT_FOR_TESTING_MESSAGE.getValue()).sendKeys("Submit for testing " + componentName);
83 GeneralUIUtils.ultimateWait();
84 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue());
85 GeneralUIUtils.ultimateWait();
86 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue(), 60);
87 GeneralUIUtils.ultimateWait();;
90 public static void clickCheckoutButton() throws Exception{
91 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on CHECKOUT button ...");
92 GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CHECKOUT_BUTTON.getValue());
93 GeneralUIUtils.ultimateWait();
96 public static void clickDeleteVersionButton() throws Exception {
97 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on DELETE VERSION button ...");
98 GeneralUIUtils.ultimateWait();
99 GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.DELETE_VERSION_BUTTON.getValue());
100 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.OK.getValue());
101 GeneralUIUtils.ultimateWait();
104 public static void clickRevertButton() throws Exception{
105 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on REVERT button ...");
106 GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.REVERT_BUTTON.getValue());
109 public static String getLifeCycleState() {
110 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()).getText();
113 public static void selectVersion(String version) {
114 GeneralUIUtils.getSelectList(version, DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue());
115 GeneralUIUtils.ultimateWait();
118 public static List<WebElement> getElemenetsFromTable() {
119 GeneralUIUtils.ultimateWait();;
120 return GeneralUIUtils.getElemenetsFromTable(By.className("flex-container"));
123 public static boolean checkElementsCountInTable(int expectedElementsCount) {
124 return checkElementsCountInTable(expectedElementsCount, () -> getElemenetsFromTable());
128 public static void clickTrashButtonAndConfirm() throws InterruptedException{
129 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on TRASH button ...");
130 GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.DELETE_VERSION_BUTTON.getValue());
134 public static boolean checkElementsCountInTable(int expectedElementsCount, Supplier<List<WebElement>> func) {
135 SetupCDTest.getExtendTest().log(Status.INFO, "Checking the number of elements in the table; should be " + (expectedElementsCount - 1));
136 // int maxWaitingPeriodMS = 10*1000;
137 // int napPeriodMS = 200;
138 // int sumOfWaiting = 0;
139 // List<WebElement> elements = null;
140 // boolean isKeepWaiting = false;
141 // while (!isKeepWaiting) {
142 // GeneralUIUtils.sleep(napPeriodMS);
143 // sumOfWaiting += napPeriodMS;
144 // elements = func.get();
145 // isKeepWaiting = (expectedElementsCount == elements.size());
146 // if (sumOfWaiting > maxWaitingPeriodMS)
149 GeneralUIUtils.ultimateWait();
153 public static void clickDeleteFile() throws Exception{
154 SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on delete file X-button ...");
155 GeneralUIUtils.clickOnAreaJS(GeneralUIUtils.getWebElementBy
156 (By.cssSelector("div[class='i-sdc-form-file-upload-x-btn']")));
157 GeneralUIUtils.ultimateWait();;