Added oparent to sdc main
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / pages / VspValidationPage.java
1 /**
2  * Copyright (c) 2019 Vodafone Group
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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
17 package org.openecomp.sdc.ci.tests.pages;
18
19 import com.aventstack.extentreports.Status;
20 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
21 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
22 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
23 import org.openqa.selenium.WebElement;
24 import org.openqa.selenium.*;
25 import static org.testng.AssertJUnit.assertTrue;
26
27
28 import java.util.List;
29
30 public class VspValidationPage extends GeneralPageElements {
31
32     public VspValidationPage() { super(); }
33
34     public static void navigateToVspValidationPageUsingNavbar() throws Exception {
35         clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR);
36     }
37
38     public static void navigateToVspValidationPageUsingBreadcrumbs() throws Exception {
39         clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_BREADCRUMBS);
40     }
41
42     public static void clickOnNextButton() throws Exception {
43         clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON);
44     }
45
46     public static void clickOnBackButton() throws Exception {
47         clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_SETUP_BUTTON);
48     }
49
50     public static void clickOnSubmitButton() throws Exception {
51         clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_RESULTS_BUTTON);
52     }
53
54     public static boolean checkNextButtonDisabled() throws Exception {
55         return GeneralUIUtils.isElementDisabled(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON.getValue());
56     }
57
58     public static void clickCertificationQueryAll() throws Exception {
59         List<WebElement> checkboxes = GeneralUIUtils.findElementsByXpath("//div[@data-test-id='vsp-validation-certifications-query-checkbox-tree']//label//span[@class='rct-checkbox']");
60         if(checkboxes.size() > 0){
61             checkboxes.get(0).click();
62         }
63         else
64             assertTrue("Checkbox Not Found", checkboxes.size() > 0);
65     }
66
67     public static void clickComplianceChecksAll() throws Exception {
68         List<WebElement> checkboxes = GeneralUIUtils.findElementsByXpath("//div[@data-test-id='vsp-validation-compliance-checks-checkbox-tree']//label//span[@class='rct-checkbox']");
69         if(checkboxes.size() > 0)
70             checkboxes.get(checkboxes.size() - 1).click();
71         else
72             assertTrue("Checkbox Not Found", checkboxes.size() > 0);
73     }
74
75     public static boolean checkCertificationQueryExists() throws Exception {
76         WebElement parentDiv = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_CERTIFICATION_CHECKBOX_TREE.getValue());
77         List<WebElement> checkboxTreeDivs = getChildElements(parentDiv);
78         List<WebElement> orderedList = getChildElements(checkboxTreeDivs.get(0));
79         return (orderedList.size() > 0);
80     }
81
82     public static boolean checkComplianceCheckExists() throws Exception {
83         WebElement parentDiv = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_COMPLIANCE_CHECKBOX_TREE.getValue());
84         List<WebElement> checkboxTreeDivs = getChildElements(parentDiv);
85         List<WebElement> orderedList = getChildElements(checkboxTreeDivs.get(0));
86         return (orderedList.size() > 0);
87     }
88
89     public static boolean checkSelectedComplianceCheckExists() throws Exception {
90         WebElement selectedTests = GeneralUIUtils.findElementsByXpath("//div[contains(text(),'Selected Compliance Tests')]/..//select[@class='validation-setup-selected-tests']").get(0);
91         List<WebElement> options = getChildElements(selectedTests);
92         return (!options.isEmpty());
93     }
94
95     public static boolean checkSelectedCertificationQueryExists() throws Exception {
96         WebElement selectedTests = GeneralUIUtils.findElementsByXpath("//div[contains(text(),'Selected Certifications Query')]/..//select[@class='validation-setup-selected-tests']").get(0);
97         List<WebElement> options = getChildElements(selectedTests);
98         return (!options.isEmpty());
99     }
100
101     public static void clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage elementTestId) throws Exception {
102         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", elementTestId.name()));
103         GeneralUIUtils.getWebElementByTestID(elementTestId.getValue()).click();
104         GeneralUIUtils.ultimateWait();
105     }
106
107     private static List<WebElement> getChildElements(WebElement webElement) throws Exception {
108         return webElement.findElements(By.xpath(".//*"));
109     }
110
111
112 }