2 * Copyright (c) 2019 Vodafone Group
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
8 * 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.
17 package org.openecomp.sdc.ci.tests.pages;
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;
28 import java.util.List;
30 public class VspValidationPage extends GeneralPageElements {
32 public VspValidationPage() { super(); }
34 public static void navigateToVspValidationPageUsingNavbar() throws Exception {
35 clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR);
38 public static void navigateToVspValidationPageUsingBreadcrumbs() throws Exception {
39 clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_BREADCRUMBS);
42 public static void clickOnNextButton() throws Exception {
43 clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON);
46 public static void clickOnBackButton() throws Exception {
47 clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_SETUP_BUTTON);
50 public static void clickOnSubmitButton() throws Exception {
51 clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_RESULTS_BUTTON);
54 public static boolean checkNextButtonDisabled() throws Exception {
55 return GeneralUIUtils.isElementDisabled(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON.getValue());
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();
64 assertTrue("Checkbox Not Found", checkboxes.size() > 0);
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();
72 assertTrue("Checkbox Not Found", checkboxes.size() > 0);
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);
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);
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());
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());
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();
107 private static List<WebElement> getChildElements(WebElement webElement) throws Exception {
108 return webElement.findElements(By.xpath(".//*"));