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.By;
24 import org.openqa.selenium.WebElement;
26 import java.util.List;
28 import static org.testng.AssertJUnit.assertTrue;
30 public class VspValidationPage extends GeneralPageElements {
32 private VspValidationPage() {
36 public static void navigateToVspValidationPageUsingNavbar() throws Exception {
37 clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR);
40 public static void navigateToVspValidationPageUsingBreadcrumbs() throws Exception {
41 clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_BREADCRUMBS);
44 public static void clickOnNextButton() throws Exception {
45 clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON);
48 public static void clickOnBackButton() throws Exception {
49 clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_SETUP_BUTTON);
52 public static void clickOnSubmitButton() throws Exception {
53 clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_RESULTS_BUTTON);
56 public static boolean checkNextButtonDisabled() throws Exception {
57 return GeneralUIUtils.isElementDisabled(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON.getValue());
60 public static void clickCertificationQueryAll() throws Exception {
61 List<WebElement> checkboxes = GeneralUIUtils.findElementsByXpath("//div[@data-test-id='vsp-validation-certifications-query-checkbox-tree']//label//span[@class='rct-checkbox']");
62 if (checkboxes.size() > 0) {
63 checkboxes.get(0).click();
65 assertTrue("Checkbox Not Found", checkboxes.size() > 0);
69 public static void clickComplianceChecksAll() throws Exception {
70 List<WebElement> checkboxes = GeneralUIUtils.findElementsByXpath("//div[@data-test-id='vsp-validation-compliance-checks-checkbox-tree']//label//span[@class='rct-checkbox']");
71 if (checkboxes.size() > 0) {
72 checkboxes.get(checkboxes.size() - 1).click();
74 assertTrue("Checkbox Not Found", checkboxes.size() > 0);
78 public static boolean checkCertificationQueryExists() throws Exception {
79 WebElement parentDiv = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_CERTIFICATION_CHECKBOX_TREE.getValue());
80 List<WebElement> checkboxTreeDivs = getChildElements(parentDiv);
81 List<WebElement> orderedList = getChildElements(checkboxTreeDivs.get(0));
82 return (orderedList.size() > 0);
85 public static boolean checkComplianceCheckExists() throws Exception {
86 WebElement parentDiv = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_COMPLIANCE_CHECKBOX_TREE.getValue());
87 List<WebElement> checkboxTreeDivs = getChildElements(parentDiv);
88 List<WebElement> orderedList = getChildElements(checkboxTreeDivs.get(0));
89 return (orderedList.size() > 0);
92 public static boolean checkSelectedComplianceCheckExists() throws Exception {
93 WebElement selectedTests = GeneralUIUtils.findElementsByXpath("//div[contains(text(),'Selected Compliance Tests')]/..//select[@class='validation-setup-selected-tests']").get(0);
94 List<WebElement> options = getChildElements(selectedTests);
95 return (!options.isEmpty());
98 public static boolean checkSelectedCertificationQueryExists() throws Exception {
99 WebElement selectedTests = GeneralUIUtils.findElementsByXpath("//div[contains(text(),'Selected Certifications Query')]/..//select[@class='validation-setup-selected-tests']").get(0);
100 List<WebElement> options = getChildElements(selectedTests);
101 return (!options.isEmpty());
104 public static void clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage elementTestId) throws Exception {
105 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", elementTestId.name()));
106 GeneralUIUtils.getWebElementByTestID(elementTestId.getValue()).click();
107 GeneralUIUtils.ultimateWait();
110 private static List<WebElement> getChildElements(WebElement webElement) throws Exception {
111 return webElement.findElements(By.xpath(".//*"));