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;
21 import java.util.List;
22 import org.apache.commons.collections.CollectionUtils;
23 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
24 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
25 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
26 import org.openqa.selenium.By;
27 import org.openqa.selenium.WebElement;
28 import org.testng.Assert;
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 void loadVSPFile(String path, String filename) {
57 List<WebElement> checkboxes =
58 GeneralUIUtils.findElementsByXpath("//div[@class='validation-input-wrapper']//input");
59 boolean hasValue = CollectionUtils.isNotEmpty(checkboxes);
61 WebElement browseWebElement = checkboxes.get(0);
62 browseWebElement.sendKeys(path + File.separator + filename);
63 GeneralUIUtils.ultimateWait();
65 Assert.fail("Did not find File input field in the page for loading VSP test file");
69 public static boolean checkNextButtonDisabled() throws Exception {
70 return GeneralUIUtils.isElementDisabled(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON.getValue());
73 public static void clickCertificationQueryAll() throws Exception {
74 List<WebElement> checkboxes = GeneralUIUtils.findElementsByXpath("//div[@data-test-id='vsp-validation-certifications-query-checkbox-tree']//label//span[@class='rct-checkbox']");
75 if (!checkboxes.isEmpty()) {
76 checkboxes.get(0).click();
78 Assert.fail("Did not find certification test checkbox in the page");
82 public static void clickComplianceChecksAll() throws Exception {
83 List<WebElement> vnfComplianceCheckboxes = GeneralUIUtils.findElementsByXpath("//div[@data-test-id='vsp-validation-compliance-checks-checkbox-tree']//span[@class='rct-text' and .//label//text()='vnf-compliance']//button");
84 if (!vnfComplianceCheckboxes.isEmpty()) {
85 vnfComplianceCheckboxes.get(vnfComplianceCheckboxes.size() - 1).click();
87 Assert.fail("Did not find vnf-compliance test checkbox in the page");
89 List<WebElement> checkboxes = GeneralUIUtils.findElementsByXpath("//div[@data-test-id='vsp-validation-compliance-checks-checkbox-tree']//label//span[@class='rct-title' and text()='csar-validate']");
90 if (!checkboxes.isEmpty()) {
91 checkboxes.get(checkboxes.size() - 1).click();
93 Assert.fail("Did not find csar-validate test Checkbox in the page");
97 public static boolean checkCertificationQueryExists() throws Exception {
98 WebElement parentDiv = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_CERTIFICATION_CHECKBOX_TREE.getValue());
99 List<WebElement> checkboxTreeDivs = getChildElements(parentDiv);
100 List<WebElement> orderedList = getChildElements(checkboxTreeDivs.get(0));
101 return (!orderedList.isEmpty());
104 public static boolean checkComplianceCheckExists() throws Exception {
105 WebElement parentDiv = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_COMPLIANCE_CHECKBOX_TREE.getValue());
106 List<WebElement> checkboxTreeDivs = getChildElements(parentDiv);
107 List<WebElement> orderedList = getChildElements(checkboxTreeDivs.get(0));
108 return (!orderedList.isEmpty());
111 public static boolean checkSelectedComplianceCheckExists() throws Exception {
112 WebElement selectedTests = GeneralUIUtils.findElementsByXpath("//div[contains(text(),'Selected Compliance Tests')]/..//select[@class='validation-setup-selected-tests']").get(0);
113 List<WebElement> options = getChildElements(selectedTests);
114 return (!options.isEmpty());
117 public static boolean checkSelectedCertificationQueryExists() throws Exception {
118 WebElement selectedTests = GeneralUIUtils.findElementsByXpath("//div[contains(text(),'Selected Certifications Query')]/..//select[@class='validation-setup-selected-tests']").get(0);
119 List<WebElement> options = getChildElements(selectedTests);
120 return (!options.isEmpty());
123 public static void clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage elementTestId) throws Exception {
124 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", elementTestId.name()));
125 GeneralUIUtils.getWebElementByTestID(elementTestId.getValue()).click();
126 GeneralUIUtils.ultimateWait();
129 private static List<WebElement> getChildElements(WebElement webElement) throws Exception {
130 return webElement.findElements(By.xpath(".//*"));