summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/att/ecomp/dcae/ci/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/att/ecomp/dcae/ci/ui')
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAECompositionPage.java70
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java41
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java27
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java28
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEServicesPage.java38
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateServicePage.java175
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java123
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCHomePage.java60
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java143
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/TranslateResult.java32
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/BaseComponenet.java15
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/HomePage.java113
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/LoginPage.java39
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RuleComponent.java40
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RulePopup.java141
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java48
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionType.java7
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ConcatActionComponent.java31
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/CopyActionComponent.java24
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/MapActionComponent.java44
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/DeleteableFromComponent.java26
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/RegexFromComponent.java38
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/SimpleFromComponent.java34
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/condition/ConditionComponent.java34
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/tests/SanityTest.java150
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java83
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/setup/DcaeConfiguration.java48
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java99
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/tests/SanityTest.java108
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/tests/ServiceTest.java42
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/CompositionVerificator.java16
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/ServiceVerificator.java22
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/utils/ByTest.java17
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/utils/Locator.java74
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFilter.java28
-rw-r--r--src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFinder.java28
36 files changed, 2086 insertions, 0 deletions
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAECompositionPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAECompositionPage.java
new file mode 100644
index 0000000..9098d23
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAECompositionPage.java
@@ -0,0 +1,70 @@
+package com.att.ecomp.dcae.ci.ui.pages;
+
+import org.openecomp.d2.ci.report.ExtentTestActions;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.Select;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.tests.verificator.CompositionVerificator;
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class DCAECompositionPage {
+
+ public static WebElement expandList(String listname)
+ {
+ ExtentTestActions.log(Status.INFO,String.format("Expand %s list", listname));
+ GeneralUIUtils.clickOnElementByTestId(listname);
+ GeneralUIUtils.ultimateWait();
+ WebDriver driver = GeneralUIUtils.getDriver();
+ WebDriverWait wait = new WebDriverWait(driver, 10);
+ WebElement categoryElement = driver.findElement(ByTest.id(listname)).findElement(By.xpath("./.."));
+ return wait.until(Locator.from(categoryElement).findVisible(By.cssSelector(".draggable"), 0));
+ }
+
+ public static void addItemFromList(WebElement item)
+ {
+ ExtentTestActions.log(Status.INFO,String.format("Click on %s item", item.getText()));
+ item.click();
+ GeneralUIUtils.ultimateWait();
+
+ }
+
+ public static void clickSave()
+ {
+ ExtentTestActions.log(Status.INFO,"Click save button");
+ GeneralUIUtils.clickOnElementByTestId("SaveButton");
+ GeneralUIUtils.ultimateWait();
+ GeneralUIUtils.waitForElementInVisibilityByTestId("saveMsg");
+ String actualSaveRes = GeneralUIUtils.getWebElementByTestID("saveMsg").getText();
+ CompositionVerificator.verifySaveSuccessfully(actualSaveRes);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void clickSubmit()
+ {
+ ExtentTestActions.log(Status.INFO,"Click submit button");
+ GeneralUIUtils.clickOnElementByTestId("SubmitButton");
+ GeneralUIUtils.ultimateWait();
+ GeneralUIUtils.waitForElementInVisibilityByTestId("submitMsg");
+ String actualSubmitRes = GeneralUIUtils.getWebElementByTestID("submitMsg").getText();
+ CompositionVerificator.verifySubmitSuccessfully(actualSubmitRes);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void SelectFlowType(String flowType) {
+ Report.log(Status.INFO, "Selecting flow type '%s'", flowType);
+ WebDriver driver = GeneralUIUtils.getDriver();
+ Select flowTypeSelect = new Select(driver.findElement(ByTest.id("flowTypeSelect")));
+ flowTypeSelect.selectByVisibleText(flowType);
+ }
+}
+
+
+
+
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java
new file mode 100644
index 0000000..f1f947a
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEGeneralPage.java
@@ -0,0 +1,41 @@
+package com.att.ecomp.dcae.ci.ui.pages;
+
+import java.util.UUID;
+
+import org.openecomp.d2.ci.report.ExtentTestActions;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+import org.openqa.selenium.WebElement;
+import com.aventstack.extentreports.Status;
+
+public class DCAEGeneralPage {
+
+ public static String addAssetName(String name)
+ {
+ WebElement nameTextbox = GeneralUIUtils.getWebElementByTestID("name");
+ String assetName = name + UUID.randomUUID();
+ nameTextbox.clear();
+ nameTextbox.sendKeys(assetName);
+ GeneralUIUtils.ultimateWait();
+ ExtentTestActions.log(Status.INFO,String.format("Add asset name: %s.", assetName));
+ return assetName;
+ }
+
+ public static void addAssetDescription(String description)
+ {
+ ExtentTestActions.log(Status.INFO,"Add asset description");
+ WebElement descriptionTextbox = GeneralUIUtils.getWebElementByTestID("description");
+ descriptionTextbox.clear();
+ descriptionTextbox.sendKeys(description);
+ GeneralUIUtils.ultimateWait();
+ }
+
+
+ public static void clickSaveAsset() throws Exception
+ {
+ ExtentTestActions.log(Status.INFO,"Click Save asset");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("Save-General");
+ GeneralUIUtils.clickOnElementByTestId("Save-General");
+ GeneralUIUtils.ultimateWait();
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java
new file mode 100644
index 0000000..17ee026
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEHomePage.java
@@ -0,0 +1,27 @@
+package com.att.ecomp.dcae.ci.ui.pages;
+
+
+import org.openecomp.d2.ci.report.ExtentTestActions;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+
+import com.aventstack.extentreports.Status;
+
+
+public class DCAEHomePage {
+
+
+
+ public static void clickOnDcaeTab()
+ {
+ ExtentTestActions.log(Status.INFO,"Clicking on DCAE Tab");
+ GeneralUIUtils.clickOnElementByTestId("main-menu-button-dcae");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void clickOnCreateNewAsset()
+ {
+ ExtentTestActions.log(Status.INFO,"Clicking on Create new asset button");
+ GeneralUIUtils.clickOnElementByTestId("AddButtonsArea");
+ GeneralUIUtils.ultimateWait();
+ }
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java
new file mode 100644
index 0000000..563c42b
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAELeftPanel.java
@@ -0,0 +1,28 @@
+package com.att.ecomp.dcae.ci.ui.pages;
+
+
+
+import org.openecomp.d2.ci.report.ExtentTestActions;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+
+import com.aventstack.extentreports.Status;
+
+public class DCAELeftPanel {
+
+ public static void navigateToServices()
+ {
+ ExtentTestActions.log(Status.INFO,"Navigate to Services internal tab");
+ GeneralUIUtils.clickOnElementByTestId("dcae-menu-item-Services");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void navigateToComposition()
+ {
+ ExtentTestActions.log(Status.INFO,"Navigate to Composition internal tab");
+ GeneralUIUtils.clickOnElementByTestId("dcae-menu-item-Composition");
+ GeneralUIUtils.ultimateWait();
+ }
+
+
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEServicesPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEServicesPage.java
new file mode 100644
index 0000000..f935715
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/DCAEServicesPage.java
@@ -0,0 +1,38 @@
+package com.att.ecomp.dcae.ci.ui.pages;
+
+
+import org.openecomp.d2.ci.report.ExtentTestActions;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+
+import com.aventstack.extentreports.Status;
+
+public class DCAEServicesPage {
+
+ public static void selectService(String serviceName)
+ {
+ GeneralUIUtils.ultimateWait();
+ ExtentTestActions.log(Status.INFO,String.format("Select Service: %s from services dropdown", serviceName));
+ GeneralUIUtils.getSelectList(serviceName, "Service Name SelectList");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void selectVNFI(String VNFIName)
+ {
+ GeneralUIUtils.ultimateWait();
+ VNFIName = VNFIName + " 0";
+ ExtentTestActions.log(Status.INFO,String.format("Select VNFI: %s from VNFIs dropdown", VNFIName));
+ GeneralUIUtils.getSelectList(VNFIName, "VNFI Name SelectList");
+ GeneralUIUtils.ultimateWait();
+ }
+
+
+ public static void clickAttach(String VNFIName)
+ {
+ ExtentTestActions.log(Status.INFO,"Click attach button");
+ GeneralUIUtils.clickOnElementByTestId("Attach Button");
+ GeneralUIUtils.ultimateWait();
+ VNFIName = VNFIName + " 0";
+ GeneralUIUtils.waitForElementInVisibilityByTestId(VNFIName); // Element to wait for after object is attached.
+ GeneralUIUtils.ultimateWait();
+ }
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateServicePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateServicePage.java
new file mode 100644
index 0000000..4bf9fc4
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateServicePage.java
@@ -0,0 +1,175 @@
+package com.att.ecomp.dcae.ci.ui.pages;
+
+import java.util.UUID;
+
+import org.openecomp.d2.ci.report.ExtentTestActions;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Action;
+import org.openqa.selenium.interactions.Actions;
+
+import com.aventstack.extentreports.Status;
+
+public class SDCCreateServicePage
+{
+ public static String addServiceName()
+ {
+ GeneralUIUtils.waitForElementInVisibilityByTestId("name");
+ WebElement serviceNameTextbox = GeneralUIUtils.getWebElementByTestID("name");
+ serviceNameTextbox.clear();
+ String serviceName = "Service" + UUID.randomUUID();
+ ExtentTestActions.log(Status.INFO, String.format("Add Service Name: %s", serviceName));
+ serviceNameTextbox.sendKeys(serviceName);
+ GeneralUIUtils.ultimateWait();
+ return serviceName;
+ }
+
+ public static void addServiceCategory(String category)
+ {
+ ExtentTestActions.log(Status.INFO, String.format("Add %s Category", category));
+ GeneralUIUtils.waitForElementInVisibilityByTestId("selectGeneralCategory");
+ GeneralUIUtils.getSelectList(category, "selectGeneralCategory");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void addServiceDescription()
+ {
+ ExtentTestActions.log(Status.INFO,"Add Service Desc");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("description");
+ WebElement serviceDescTextbox = GeneralUIUtils.getWebElementByTestID("description");
+ serviceDescTextbox.clear();
+ String serviceDesc = "Desc";
+ serviceDescTextbox.sendKeys(serviceDesc);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void addServiceDescriptionProjectCode()
+ {
+ ExtentTestActions.log(Status.INFO,"Add Service Project Code");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("projectCode");
+ WebElement projectCodeTextbox = GeneralUIUtils.getWebElementByTestID("projectCode");
+ projectCodeTextbox.clear();
+ String projectCode = "12345";
+ projectCodeTextbox.sendKeys(projectCode);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static String addAllServiceMandtoryFields(String category)
+ {
+ String serviceName = addServiceName();
+ addServiceCategory(category);
+ addServiceDescription();
+ addServiceDescriptionProjectCode();
+
+ return serviceName;
+ }
+
+ public static void clickOnCreateServiceButton()
+ {
+ ExtentTestActions.log(Status.INFO,"Click on Create Service Button");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("create/save");
+ GeneralUIUtils.clickOnElementByTestId("create/save");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void clickOnCheckInServiceButton()
+ {
+ ExtentTestActions.log(Status.INFO,"Click on Check In Service Button");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("check_in");
+ GeneralUIUtils.clickOnElementByTestId("check_in");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void addCheckInMessage()
+ {
+ ExtentTestActions.log(Status.INFO,"Add check in message in pop window");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("checkindialog");
+ WebElement checkInDialogTextbox = GeneralUIUtils.getWebElementByTestID("checkindialog");
+ checkInDialogTextbox.clear();
+ String vfCheckInDialog = "Text";
+ checkInDialogTextbox.sendKeys(vfCheckInDialog);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void clickOnCheckInOKFButton()
+ {
+ ExtentTestActions.log(Status.INFO,"Click OK in check in pop up window");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("OK");
+ GeneralUIUtils.clickOnElementByTestId("OK");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void checkInService()
+ {
+ clickOnCheckInServiceButton();
+ addCheckInMessage();
+ clickOnCheckInOKFButton();
+ }
+
+ public static void clickOnServiceCompsitionTab()
+ {
+ ExtentTestActions.log(Status.INFO,"Click on Service composition tab");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("CompositionLeftSideMenu");
+ GeneralUIUtils.clickOnElementByTestId("CompositionLeftSideMenu");
+ GeneralUIUtils.ultimateWait();
+ }
+
+
+ public static void searchAssetOnCompsitionTab(String assetName)
+ {
+ ExtentTestActions.log(Status.INFO,String.format("Search for %s in Service composition", assetName));
+ GeneralUIUtils.waitForElementInVisibilityByTestId("searchAsset");
+ WebElement compositionSearchTextbox = GeneralUIUtils.getWebElementByTestID("searchAsset");
+ compositionSearchTextbox.clear();
+ compositionSearchTextbox.sendKeys(assetName);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void dragAndDropAssetToCanvas(String assetName)
+ {
+ ExtentTestActions.log(Status.INFO,String.format("Drag and drop %s to Canvas", assetName));
+ GeneralUIUtils.waitForElementInVisibilityByTestId("searchAsset");
+ WebElement vfElementFrom = GeneralUIUtils.getWebElementByTestID("leftbar-section-content-item-" + assetName);
+ WebElement canvasElementTo = GeneralUIUtils.getWebElementByTestID("canvas");
+ GeneralUIUtils.ultimateWait();
+ WebDriver driver = GeneralUIUtils.getDriver();
+ Actions builder = new Actions(driver);
+ Action dragAndDrop = builder.clickAndHold(vfElementFrom).moveToElement(canvasElementTo).release(canvasElementTo).build();
+ dragAndDrop.perform();
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void addAssetToCanvas(String assetName)
+ {
+ searchAssetOnCompsitionTab(assetName);
+ dragAndDropAssetToCanvas(assetName);
+ }
+
+ public static void clickOnElementInCanavs()
+ {
+ ExtentTestActions.log(Status.INFO,"Click on VF in Canavs");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("canvas");
+ WebElement canvasElement = GeneralUIUtils.getWebElementByTestID("canvas");
+ GeneralUIUtils.ultimateWait();
+ WebDriver driver = GeneralUIUtils.getDriver();
+ Actions actions = new Actions(driver);
+ actions.moveToElement(canvasElement, 1316, 661);
+ actions.clickAndHold();
+ actions.moveToElement(canvasElement, 1316, 661);
+ actions.release();
+ actions.perform();
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void clickOnArtifactTab()
+ {
+ ExtentTestActions.log(Status.INFO,"Click on Artifcat");
+ GeneralUIUtils.getWebElementByTestID("deployment-artifact-tab");
+ GeneralUIUtils.clickOnElementByTestId("deployment-artifact-tab");
+ }
+
+
+
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java
new file mode 100644
index 0000000..d7a30ba
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCCreateVFPage.java
@@ -0,0 +1,123 @@
+package com.att.ecomp.dcae.ci.ui.pages;
+
+import java.util.UUID;
+
+import org.openecomp.d2.ci.report.ExtentTestActions;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+import org.openqa.selenium.WebElement;
+
+import com.aventstack.extentreports.Status;
+
+public class SDCCreateVFPage
+{
+ public static String addVFName()
+ {
+ GeneralUIUtils.waitForElementInVisibilityByTestId("name");
+ WebElement vfNameTextbox = GeneralUIUtils.getWebElementByTestID("name");
+ vfNameTextbox.clear();
+ String vfName = "VF" + UUID.randomUUID();
+ vfNameTextbox.sendKeys(vfName);
+ ExtentTestActions.log(Status.INFO, String.format("Add VF Name: %s",vfName));
+ GeneralUIUtils.ultimateWait();
+ return vfName;
+ }
+
+ public static void addVFCategory(String category)
+ {
+ ExtentTestActions.log(Status.INFO, String.format("Add %s Category", category));
+ GeneralUIUtils.waitForElementInVisibilityByTestId("selectGeneralCategory");
+ GeneralUIUtils.getSelectList(category, "selectGeneralCategory");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void addVFDescription()
+ {
+ ExtentTestActions.log(Status.INFO,"Add VF Desc");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("description");
+ WebElement vfdescTextbox = GeneralUIUtils.getWebElementByTestID("description");
+ vfdescTextbox.clear();
+ String vfDesc = "Desc";
+ vfdescTextbox.sendKeys(vfDesc);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void addVFVendorName()
+ {
+ ExtentTestActions.log(Status.INFO,"Add VF Vendor Name");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("vendorName");
+ WebElement vendorTextbox = GeneralUIUtils.getWebElementByTestID("vendorName");
+ vendorTextbox.clear();
+ String vfVendorName = "Vendor";
+ vendorTextbox.sendKeys(vfVendorName);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void addVFVendorRelease()
+ {
+ ExtentTestActions.log(Status.INFO,"Add VF Vendor Release");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("vendorRelease");
+ WebElement vendorReleaseTextbox = GeneralUIUtils.getWebElementByTestID("vendorRelease");
+ vendorReleaseTextbox.clear();
+ String vfVendorRelease = "1";
+ vendorReleaseTextbox.sendKeys(vfVendorRelease);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static String addAllVFMandtoryFields(String category)
+ {
+ String vfName = addVFName();
+ addVFCategory(category);
+ addVFDescription();
+ addVFVendorName();
+ addVFVendorRelease();
+
+ return vfName;
+ }
+
+ public static void clickOnCreateVFButton()
+ {
+ ExtentTestActions.log(Status.INFO,"Click on Create VF Button");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("create/save");
+ GeneralUIUtils.clickOnElementByTestId("create/save");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void clickOnCheckInVFButton()
+ {
+ ExtentTestActions.log(Status.INFO,"Click on Check In VF Button");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("check_in");
+ GeneralUIUtils.clickOnElementByTestId("check_in");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void addCheckInMessage()
+ {
+ ExtentTestActions.log(Status.INFO,"Add check in message in pop window");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("checkindialog");
+ WebElement checkInDialogTextbox = GeneralUIUtils.getWebElementByTestID("checkindialog");
+ checkInDialogTextbox.clear();
+ String vfCheckInDialog = "Text";
+ checkInDialogTextbox.sendKeys(vfCheckInDialog);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void clickOnCheckInOKFButton()
+ {
+ ExtentTestActions.log(Status.INFO,"Click OK in check in pop up window");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("OK");
+ GeneralUIUtils.clickOnElementByTestId("OK");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void checkInVF()
+ {
+ clickOnCheckInVFButton();
+ addCheckInMessage();
+ clickOnCheckInOKFButton();
+ }
+
+
+
+
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCHomePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCHomePage.java
new file mode 100644
index 0000000..00a4e4e
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/pages/SDCHomePage.java
@@ -0,0 +1,60 @@
+package com.att.ecomp.dcae.ci.ui.pages;
+
+import org.openecomp.d2.ci.report.ExtentTestActions;
+import org.openecomp.d2.ci.setup.SetupCDTest;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+import org.openqa.selenium.WebElement;
+
+import com.att.ecomp.dcae.ci.utilities.ConfigurationReader;
+import com.aventstack.extentreports.Status;
+
+public class SDCHomePage
+{
+
+ public static void clickOnAddVf()
+ {
+ ExtentTestActions.log(Status.INFO,"Clicking on Add VF button");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("AddButtonsArea");
+ GeneralUIUtils.hoverOnAreaByTestId("AddButtonsArea");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("createResourceButton");
+ GeneralUIUtils.clickOnElementByTestId("createResourceButton");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void clickOnAddsService()
+ {
+ ExtentTestActions.log(Status.INFO,"Clicking on Add Service button");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("AddButtonsArea");
+ GeneralUIUtils.hoverOnAreaByTestId("AddButtonsArea");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("createServiceButton");
+ GeneralUIUtils.clickOnElementByTestId("createServiceButton");
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void searchForElement(String name)
+ {
+ ExtentTestActions.log(Status.INFO,"Search for element in Homepage");
+ GeneralUIUtils.waitForElementInVisibilityByTestId("main-menu-input-search");
+ WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID("main-menu-input-search");
+ searchTextbox.clear();
+ searchTextbox.sendKeys(name);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void clickOnElement(String name)
+ {
+ ExtentTestActions.log(Status.INFO,"Clicking on Add VF button");
+ GeneralUIUtils.waitForElementInVisibilityByTestId(name);
+ GeneralUIUtils.clickOnElementByTestId(name);
+ GeneralUIUtils.ultimateWait();
+ }
+
+ public static void clickOnHomeTab() throws Exception {
+ ExtentTestActions.log(Status.INFO,"Navigate to SDC Homepage");
+ GeneralUIUtils.clickOnElementByCSS("div[class=triangle] span"); // Temp workaround... need to click by data-tests-id
+ GeneralUIUtils.ultimateWait();
+ GeneralUIUtils.clickOnElementByTestId("sub-menu-button-home");
+ GeneralUIUtils.ultimateWait();
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java
new file mode 100644
index 0000000..a197dd3
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/BaseTest.java
@@ -0,0 +1,143 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor;
+
+import java.io.File;
+import java.util.Map;
+
+import org.openecomp.d2.ci.datatypes.Configuration;
+import org.openecomp.d2.ci.datatypes.UserCredentials;
+import org.openecomp.d2.ci.datatypes.UserRoleEnum;
+import org.openecomp.d2.ci.datatypes.http.RestResponse;
+import org.openecomp.d2.ci.setup.DriverFactory;
+import org.openecomp.d2.ci.utilities.FileHandling;
+import org.onap.sdc.dcae.composition.vfcmt.Vfcmt;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.web.util.UriComponentsBuilder;
+import org.testng.annotations.BeforeMethod;
+
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.LoginPage;
+import com.att.ecomp.dcae.ci.utilities.ConfigurationReader;
+import com.att.ecomp.dcae.ci.utilities.DcaeEntityClient;
+import com.att.ecomp.dcae.ci.utilities.DcaeRestClient;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class BaseTest extends DriverFactory {
+
+ private String baseUrl = ConfigurationReader.getConfiguration().getRuleEditorUrl();
+ private final long defaultTimeout = 90;
+ protected WebDriverWait defaultTimeoutWait;
+
+ @BeforeMethod
+ protected void setupTest(){
+ try {
+ /**
+ * this is surrounded by a try block because of a bug in TestNg that causes 'afterMethod' to not be called
+ * when an exception is thrown in the 'beforeMethod' - this prevents the ExtentReport from producing a report
+ */
+
+ Report.log(Status.INFO, "Setting up...");
+ LinkedMultiValueMap<String, String> params = arrangeRequiredParams();
+ String url = UriComponentsBuilder.fromHttpUrl(baseUrl).queryParams(params).build().toUriString();
+ Report.log(Status.INFO, "Deleting cookies...");
+ WebDriver driver = getDriver();
+ driver.manage().deleteAllCookies();
+ Report.log(Status.INFO, "Navigating to URL: %s", url);
+ driver.navigate().to(url);
+ Report.log(Status.INFO, "Checking if diverted to login page...");
+ defaultTimeoutWait = new WebDriverWait(driver, defaultTimeout);
+ if (LoginPage.isCurrentPage(driver)) {
+ Report.log(Status.INFO, "Preforming login...");
+ WebElement root = driver.findElement(By.cssSelector("body"));
+ LoginPage loginPage = new LoginPage(defaultTimeoutWait, root);
+ loginPage.login(getUserCredentials());
+ Report.log(Status.INFO, "Refreshing...");
+ driver.navigate().refresh(); // refresh fixes missing cookies after login
+ Report.log(Status.INFO, "Logged-in successfully.");
+ } else {
+ Report.log(Status.INFO, "Not in login page.");
+ }
+ Report.log(Status.INFO, "Setup done.");
+ } catch (Exception err) {
+ Report.fatal("Error during setup", err);
+ }
+ }
+
+ protected LinkedMultiValueMap<String, String> arrangeRequiredParams() throws Exception {
+ String userId = getUserCredentials().getUserId();
+ DcaeEntityClient dcaeEntityClient = new DcaeEntityClient();
+ Report.log(Status.INFO, "Creating vfcmt...");
+ Vfcmt vfcmt = dcaeEntityClient.createVfcmt(userId);
+// Report.log(Status.INFO, "Generating cdump of snmp (simulated drag of snmp component)...");
+ String cdump = getFakeCdump();
+ Report.log(Status.INFO, "Saving composition...");
+ RestResponse saveResponse = DcaeRestClient.saveComposition(vfcmt.getUuid(), userId, cdump);
+ if (saveResponse.getStatusCode() != 200) {
+ throw new Exception("Save composition failed.\nDetails: " + saveResponse.toString());
+ }
+ LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
+ params.add("vfcmtUuid", vfcmt.getUuid());
+ params.add("nodeName", "map");
+ params.add("nodeId", "map");
+ params.add("fieldName", "fake");
+ params.add("userId", userId);
+ params.add("flowType", "FOI");
+ return params;
+ }
+
+ protected LinkedMultiValueMap<String, String> arrangeFakeParams() {
+ LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
+ params.add("vfcmtUuid", "aece8152-a97f-4ec4-9a42-941d8e586f97");
+ params.add("nodeName", "map");
+ params.add("nodeId", "map");
+ params.add("fieldName", "fake");
+ params.add("userId", "fakeo");
+ params.add("flowType", "FOI");
+ return params;
+ }
+
+ private static String getFakeCdump() {
+ return "{\"nid\":\"map\"}";
+ }
+
+ protected UserRoleEnum getUserRole()
+ {
+ return UserRoleEnum.DESIGNER;
+ }
+
+ @Override
+ protected Configuration getEnvConfiguration() {
+ return ConfigurationReader.getConfiguration();
+ }
+
+ @Override
+ protected UserCredentials getUserCredentials() {
+ try {
+ String userRole = getUserRole().name().toLowerCase();
+ String credentialsFile = System.getProperty("credentials.file");
+ if (credentialsFile == null)
+ credentialsFile = ConfigurationReader.confPath() + "credentials.yaml";
+ File file = new File(credentialsFile);
+ if (!file.exists()){
+ throw new Exception("Please provide a credentails file");
+ }
+ Map<?, ?> credentialsParsedFile = FileHandling.parseYamlFile(credentialsFile);
+ Map<String, String> credentialsMap = (Map<String, String>) credentialsParsedFile.get(userRole);
+ String userId = (String) credentialsMap.get("username");
+ String password = (String) credentialsMap.get("password");
+ String firstname = (String) credentialsMap.get("firstname");
+ String lastname = (String) credentialsMap.get("lastname");
+
+ return new UserCredentials(userId, password, firstname, lastname, null);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/TranslateResult.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/TranslateResult.java
new file mode 100644
index 0000000..22545b9
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/TranslateResult.java
@@ -0,0 +1,32 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor;
+
+import com.fasterxml.jackson.annotation.*;
+
+public class TranslateResult {
+
+ public enum Status {
+ ok,
+ error
+ }
+
+ private Status status;
+ private String data;
+
+ @JsonCreator
+ public TranslateResult(
+ @JsonProperty("status") Status status,
+ @JsonProperty("data") String data) {
+
+ this.status = status;
+ this.data = data;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/BaseComponenet.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/BaseComponenet.java
new file mode 100644
index 0000000..c159af9
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/BaseComponenet.java
@@ -0,0 +1,15 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+public class BaseComponenet {
+
+ protected WebDriverWait wait;
+ protected WebElement root;
+
+ public BaseComponenet(WebDriverWait timeout, WebElement element) {
+ this.wait = timeout;
+ this.root = element;
+ }
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/HomePage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/HomePage.java
new file mode 100644
index 0000000..47ab468
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/HomePage.java
@@ -0,0 +1,113 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components;
+
+import static org.testng.Assert.fail;
+
+import java.util.Arrays;
+
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.Select;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.rule_editor.TranslateResult;
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class HomePage extends BaseComponenet {
+
+ public HomePage(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public void waitForLoaderFinish() {
+ Report.log(Status.INFO, "Wait for loader finish...");
+ ByTest loaderTestId = ByTest.id("loader");
+ WebElement loader = wait.until(Locator.from(root).find(loaderTestId, 0)); // wait until loader appears
+ wait.until(ExpectedConditions.invisibilityOfAllElements(Arrays.asList(loader))); // wait until loader disappears
+ }
+
+ public void load(String version, String eventType) {
+ Report.log(Status.INFO, "Selecting version...");
+ select(ByTest.id("selectVersion"), version);
+ Report.log(Status.INFO, "Selecting event-type...");
+ select(ByTest.id("selectEventType"), eventType);
+ }
+
+ public RuleComponent getRule(int index) {
+ WebElement ruleElement = wait.until(Locator.from(root).findVisible(ByTest.id("ruleElement"), index));
+ return new RuleComponent(wait, ruleElement);
+ }
+
+ private WebElement getRulePopupElem() {
+ return wait.until(Locator.from(root).findVisible(ByTest.id("popupRuleEditor"), 0));
+ }
+
+ public WebElement getRoot() {
+ return root;
+ }
+
+ public RulePopup clickAddFirstRule() {
+ Report.log(Status.INFO, "Clicking add-rule...");
+ wait.until(Locator.from(root).findVisible(ByTest.id("btnAddFirstRule"), 0)).click();
+ WebElement popupAddRule = getRulePopupElem();
+ Report.log(Status.INFO, "Rule popup visible");
+ return new RulePopup(wait, popupAddRule);
+ }
+
+ public RulePopup clickAddMoreRule() {
+ Report.log(Status.INFO, "Clicking add-rule...");
+ wait.until(Locator.from(root).findVisible(ByTest.id("addMoreRule"), 0)).click();
+ WebElement popupAddRule = getRulePopupElem();
+ Report.log(Status.INFO, "Rule popup visible");
+ return new RulePopup(wait, popupAddRule);
+ }
+
+ public void clickOnRuleDeleteConfirmPopup (){
+ Report.log(Status.INFO, "Click on delete on popup confirmation");
+ WebElement deletePopup = wait.until(Locator.from(root).findVisible(ByTest.id("delete-popup"), 0));
+ wait.until(Locator.from(root).findVisible(ByTest.id("btnDelete"), 0)).click();
+ waitForLoaderFinish();
+ }
+
+ public void clickTranslate() {
+ Report.log(Status.INFO, "Clicking Translate...");
+ wait.until(Locator.from(root).findVisible(ByTest.id("btnTranslate"), 0)).click();
+ waitForLoaderFinish();
+ }
+
+ public void clickCancel() {
+ Report.log(Status.INFO, "Clicking Cancel...");
+ wait.until(Locator.from(root).findVisible(ByTest.id("btnCancel"), 0)).click();
+ }
+
+ public String getTranslation(WebDriver driver) throws Exception {
+ Report.log(Status.INFO, "Retriving translation result...");
+ Object result = (Object) ((JavascriptExecutor) driver).executeScript("return window.translateResult;");
+ ObjectMapper mapper = new ObjectMapper();
+ TranslateResult parsedResult = mapper.convertValue(result, TranslateResult.class);
+ switch(parsedResult.getStatus()) {
+ case error:
+ fail(String.format("translate error: %s", parsedResult.getData()));
+ break;
+ case ok:
+ Report.logDebug("translation:", parsedResult.getData());
+ return parsedResult.getData();
+ }
+ throw new Exception(String.format("invalid status argument. expected (ok/error) but got %s", parsedResult.getData()));
+ }
+
+ /* Private Methods */
+
+ private void select(ByTest by, String option) {
+ WebElement selectElement = wait.until(Locator.from(root).findVisible(by, 0));
+ wait.until(Locator.from(selectElement).find(ByTest.id("option"), 0)); // wait for dynamic options
+ Select versionSelect = new Select(selectElement);
+ versionSelect.selectByVisibleText(option);
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/LoginPage.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/LoginPage.java
new file mode 100644
index 0000000..cc17481
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/LoginPage.java
@@ -0,0 +1,39 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components;
+
+import org.openecomp.d2.ci.datatypes.UserCredentials;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class LoginPage extends BaseComponenet {
+
+ public LoginPage(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public void login(String userId, String password) {
+ Report.log(Status.INFO, "Filling input userid...");
+ root.findElement(By.name("userid")).sendKeys(userId);
+ Report.log(Status.INFO, "Filling input password...");
+ root.findElement(By.name("password")).sendKeys(password);
+ Report.log(Status.INFO, "Clicking submit...");
+ root.findElement(By.name("btnSubmit")).click();
+ Report.log(Status.INFO, "Waiting for login success page...");
+ wait.until(ExpectedConditions.titleIs("AT&T - Log On Successful"));
+ Report.log(Status.INFO, "Clicking OK...");
+ wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("successOK"))).click();
+ }
+
+ public void login(UserCredentials credentials) {
+ login(credentials.getUserId(), credentials.getPassword());
+ }
+
+ public static boolean isCurrentPage(WebDriver driver) {
+ return driver.getTitle().equals("AT&T Security Server: Login");
+ }
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RuleComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RuleComponent.java
new file mode 100644
index 0000000..94bf547
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RuleComponent.java
@@ -0,0 +1,40 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components;
+
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class RuleComponent extends BaseComponenet {
+
+ public RuleComponent(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public String getDescription(){
+ Report.log(Status.INFO, "Get rule description");
+ return root.getText();
+ }
+
+ public RulePopup clickEdit(WebDriver driver, WebElement homePageRoot){
+ Report.log(Status.INFO, "Click on edit...");
+ Actions action = new Actions(driver);
+ action.moveToElement(root).perform();
+ wait.until(Locator.from(root).findVisible(ByTest.id("editRule"), 0)).click();
+ WebElement rulePopupElem = wait.until(Locator.from(homePageRoot).findVisible(ByTest.id("popupRuleEditor"), 0));
+ return new RulePopup(wait, rulePopupElem);
+ }
+
+ public void clickDelete(WebDriver driver){
+ Report.log(Status.INFO, "Click on delete...");
+ Actions action = new Actions(driver);
+ action.moveToElement(root).perform();
+ wait.until(Locator.from(root).findVisible(ByTest.id("deleteRule"), 0)).click();
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RulePopup.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RulePopup.java
new file mode 100644
index 0000000..1cde952
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/RulePopup.java
@@ -0,0 +1,141 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components;
+
+import java.util.Arrays;
+
+import org.apache.commons.lang3.NotImplementedException;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.Select;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ActionComponent;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ActionType;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ConcatActionComponent;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.CopyActionComponent;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.MapActionComponent;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.condition.ConditionComponent;
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class RulePopup extends BaseComponenet {
+
+ public RulePopup(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public String getDescription() {
+ Report.log(Status.INFO, "get input description...");
+ return wait.until(Locator.from(root).findVisible(ByTest.id("inputDescription"), 0)).getAttribute("value");
+ }
+
+ public void setDescription(String text) {
+ Report.log(Status.INFO, "Filling input description...");
+ wait.until(Locator.from(root).findVisible(ByTest.id("inputDescription"), 0)).sendKeys(text);
+ }
+
+ public ActionComponent getAction(ActionType actionType, int index) {
+ WebElement actionElement = wait.until(Locator.from(root).findVisible(ByTest.id("action"), index));
+ ActionComponent newActionComponent = createAction(actionType, wait, actionElement);
+ return newActionComponent;
+ }
+
+ public CopyActionComponent addCopyAction(int index) {
+ return (CopyActionComponent) addAction(ActionType.Copy, index);
+ }
+
+ public ConcatActionComponent addConcatAction(int index) {
+ return (ConcatActionComponent) addAction(ActionType.Concat, index);
+ }
+
+ public MapActionComponent addMapAction(int index) {
+ return (MapActionComponent) addAction(ActionType.Map, index);
+ }
+
+ public WebElement getErrorList(){
+ return wait.until(Locator.from(root).findVisible(ByTest.id("errorList"), 0));
+ }
+
+ public void clickOnAddCondition(){
+ wait.until(Locator.from(root).find(ByTest.id("isCondition"), 0)).click();
+ }
+
+ public void addSimpleCondition(){
+ clickOnAddCondition();
+ Report.log(Status.INFO, "Create and fill simple condition");
+ ConditionComponent condition = new ConditionComponent(wait,root);
+ condition.setLeftField(0, "A");
+ condition.setRightField(0, "B");
+ condition.selectOperator(0, "Contains");
+ }
+
+ public void addComplexCondition(){
+ Report.log(Status.INFO, "Click on add condition checkbox");
+ clickOnAddCondition();
+ Report.log(Status.INFO, "Create and fill top condition");
+ ConditionComponent condition1 = new ConditionComponent(wait,root);
+ condition1.setLeftField(0, "A");
+ condition1.setRightField(0, "B");
+ condition1.selectOperator(0, "Contains");
+ Report.log(Status.INFO, "Click on add group condition");
+ wait.until(Locator.from(root).findVisible(ByTest.id("addConditionGroup"), 0)).click();
+ Report.log(Status.INFO, "Create and fill first nested condition");
+ ConditionComponent innerCondition1 = new ConditionComponent(wait,root);
+ condition1.setLeftField(1, "C");
+ condition1.setRightField(1, "D");
+ condition1.selectOperator(1, "Contains");
+ Report.log(Status.INFO, "Create and fill second nested condition");
+ ConditionComponent innerCondition2 = new ConditionComponent(wait,root);
+ condition1.setLeftField(2, "E");
+ condition1.setRightField(2, "F");
+ condition1.selectOperator(2, "Contains");
+ }
+
+ public void clickSave() {
+ Report.log(Status.INFO, "Clicking Save (changes on rule-editor)...");
+ wait.until(Locator.from(root).findVisible(ByTest.id("btnSave"), 0)).click();
+ waitForLoaderFinish();
+ }
+
+ public void clickCancel() {
+ Report.log(Status.INFO, "Clicking Cancel (changes on rule-editor)...");
+ wait.until(Locator.from(root).findVisible(ByTest.id("btnCancel"), 0)).click();
+ }
+
+
+ /* Private Methods */
+
+ private void waitForLoaderFinish() {
+ Report.log(Status.INFO, "Wait for loader finish...");
+ ByTest loaderTestId = ByTest.id("loader");
+ WebElement loader = root.findElement(loaderTestId);
+ wait.until(ExpectedConditions.invisibilityOfAllElements(Arrays.asList(loader))); // wait until loader disappears
+ }
+
+ private ActionComponent addAction(ActionType actionType, int index) {
+ Report.log(Status.INFO, "Selecting action...");
+ WebElement actionElement = wait.until(Locator.from(root).findVisible(ByTest.id("selectAction"), 0));
+ Select actionSelect = new Select(actionElement);
+ actionSelect.selectByVisibleText(actionType.toString());
+ Report.log(Status.INFO, "Clicking Add Action...");
+ wait.until(Locator.from(root).findVisible(ByTest.id("btnAddAction"), 0)).click();
+ return getAction(actionType, index);
+ }
+
+ private static ActionComponent createAction(ActionType actionType, WebDriverWait wait, WebElement newActionElement) {
+ switch (actionType) {
+ case Concat:
+ return new ConcatActionComponent(wait, newActionElement);
+ case Copy:
+ return new CopyActionComponent(wait, newActionElement);
+ case Map:
+ return new MapActionComponent(wait, newActionElement);
+ default:
+ throw new IllegalArgumentException(String.format("action type '%s' not supported", actionType));
+ }
+ }
+
+
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java
new file mode 100644
index 0000000..c12931a
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java
@@ -0,0 +1,48 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.BaseComponenet;
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class ActionComponent extends BaseComponenet {
+
+ public ActionComponent(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public void delete() {
+ Report.log(Status.INFO, "click on delete action");
+ wait.until(Locator.from(root).findVisible(ByTest.id("deleteAction"), 0)).click();
+ }
+
+ public void setTarget(String target) {
+ Report.log(Status.INFO, "Filling input target...");
+ getTargetElement().clear();
+ getTargetElement().sendKeys(target);
+ }
+
+ public void setTargetFromTree(){
+ Report.log(Status.INFO, "Pick target from tree");
+ wait.until(Locator.from(root).findVisible(ByTest.id("openTargetTree"), 0)).click();
+ Report.log(Status.INFO, "Click on tree toggle");
+ wait.until(Locator.from(root).findVisible(ByTest.cssSelector(".toggle-children-wrapper"),0)).click();
+ Report.log(Status.INFO, "Click on first target node");
+ wait.until(Locator.from(root).findVisible(ByTest.id("targetNode"), 1)).click();
+ }
+
+ public String getTarget() {
+ Report.log(Status.INFO, "get input target...");
+ return getTargetElement().getAttribute("value");
+ }
+
+ /* Private Methods */
+
+ private WebElement getTargetElement() {
+ return wait.until(Locator.from(root).findVisible(ByTest.id("inputTarget"), 0));
+ }
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionType.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionType.java
new file mode 100644
index 0000000..4cb4a28
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionType.java
@@ -0,0 +1,7 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions;
+
+public enum ActionType {
+ Copy,
+ Concat,
+ Map
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ConcatActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ConcatActionComponent.java
new file mode 100644
index 0000000..435441e
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ConcatActionComponent.java
@@ -0,0 +1,31 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.DeleteableFromComponent;
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+
+public class ConcatActionComponent extends ActionComponent {
+
+ public ConcatActionComponent(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public DeleteableFromComponent clickAddInput(int index) {
+ Report.log(Status.INFO, "Clicking on add input (another from)...");
+ wait.until(Locator.from(root).findVisible(ByTest.id("btnAddInput"), 0)).click();
+ return getFromComponent(index);
+ }
+
+ public DeleteableFromComponent getFromComponent(int index) {
+ Report.log(Status.INFO, "Getting from component at index %d...", index);
+ WebElement fromElement = wait.until(Locator.from(root).findVisible(ByTest.id("fromComponent"), index));
+ return new DeleteableFromComponent(wait, fromElement);
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/CopyActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/CopyActionComponent.java
new file mode 100644
index 0000000..3241ce6
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/CopyActionComponent.java
@@ -0,0 +1,24 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.RegexFromComponent;
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class CopyActionComponent extends ActionComponent {
+
+ public CopyActionComponent(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public RegexFromComponent getFromComponent() {
+ Report.log(Status.INFO, "Getting fromComponent...");
+ WebElement fromElement = wait.until(Locator.from(root).findVisible(ByTest.id("fromComponent"), 0));
+ return new RegexFromComponent(wait, fromElement);
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/MapActionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/MapActionComponent.java
new file mode 100644
index 0000000..37efe17
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/MapActionComponent.java
@@ -0,0 +1,44 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.RegexFromComponent;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.SimpleFromComponent;
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class MapActionComponent extends ActionComponent {
+
+ public MapActionComponent(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public SimpleFromComponent getFromComponent() {
+ Report.log(Status.INFO, "getting simple from component");
+ WebElement fromElement = wait.until(Locator.from(root).findVisible(ByTest.id("fromComponent"), 0));
+ return new SimpleFromComponent(wait, fromElement);
+ }
+
+ public void openDefaultOption(){
+ Report.log(Status.INFO, "open default opention by click on checkbox");
+ wait.until(Locator.from(root).find(ByTest.id("defaultCheckbox"), 0)).click();
+ }
+
+ public void setDefaultData(String value){
+ Report.log(Status.INFO, "set default field with a value");
+ wait.until(Locator.from(root).findVisible(ByTest.id("defaultInput"), 0)).sendKeys(value);
+ }
+
+ public void setKeyData(String value){
+ Report.log(Status.INFO, "set map key with a value");
+ wait.until(Locator.from(root).findVisible(ByTest.id("key"), 0)).sendKeys(value);
+ }
+
+ public void setValueData(String value){
+ Report.log(Status.INFO, "set map value with a value");
+ wait.until(Locator.from(root).findVisible(ByTest.id("value"), 0)).sendKeys(value);
+ }
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/DeleteableFromComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/DeleteableFromComponent.java
new file mode 100644
index 0000000..4037419
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/DeleteableFromComponent.java
@@ -0,0 +1,26 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from;
+
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class DeleteableFromComponent extends SimpleFromComponent {
+
+ public DeleteableFromComponent(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public void clickDelete(WebDriver driver) {
+ Report.log(Status.INFO, "Click on delete from...");
+ Actions action = new Actions(driver);
+ action.moveToElement(root).perform();
+ wait.until(Locator.from(root).findVisible(ByTest.id("btnDelete"), 0)).click();
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/RegexFromComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/RegexFromComponent.java
new file mode 100644
index 0000000..159d0c9
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/RegexFromComponent.java
@@ -0,0 +1,38 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class RegexFromComponent extends SimpleFromComponent {
+
+ public RegexFromComponent(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public void clickRegex() {
+ Report.log(Status.INFO, "Clicking regex button...");
+ wait.until(Locator.from(root).findVisible(ByTest.id("btnFromRegex"), 0)).click();
+ }
+
+ public String getRegex() {
+ Report.log(Status.INFO, "Getting regex from...");
+ return getRegexElement().getAttribute("value");
+ }
+
+ public void setRegex(String value) {
+ Report.log(Status.INFO, "Setting regex from...");
+ getRegexElement().clear();
+ getRegexElement().sendKeys(value);
+ }
+
+ /* Private Methods */
+
+ private WebElement getRegexElement() {
+ return wait.until(Locator.from(root).findVisible(ByTest.id("inputFromRegex"), 0));
+ }
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/SimpleFromComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/SimpleFromComponent.java
new file mode 100644
index 0000000..a7cba3d
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/from/SimpleFromComponent.java
@@ -0,0 +1,34 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.BaseComponenet;
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class SimpleFromComponent extends BaseComponenet {
+
+ public SimpleFromComponent(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public String getValue() {
+ Report.log(Status.INFO, "Getting input from...");
+ return getFromValueElement().getAttribute("value");
+ }
+
+ public void setValue(String value) {
+ Report.log(Status.INFO, "Setting input from...");
+ getFromValueElement().clear();
+ getFromValueElement().sendKeys(value);
+ }
+
+ /* Private Methods */
+
+ private WebElement getFromValueElement() {
+ return wait.until(Locator.from(root).findVisible(ByTest.id("valueInput"), 0));
+ }
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/condition/ConditionComponent.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/condition/ConditionComponent.java
new file mode 100644
index 0000000..12ab277
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/condition/ConditionComponent.java
@@ -0,0 +1,34 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.components.condition;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.Select;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.BaseComponenet;
+import com.att.ecomp.dcae.ci.ui.utils.ByTest;
+import com.att.ecomp.dcae.ci.ui.utils.Locator;
+
+public class ConditionComponent extends BaseComponenet{
+
+ public ConditionComponent(WebDriverWait timeout, WebElement element) {
+ super(timeout, element);
+ }
+
+ public void setLeftField(int index, String value){
+ WebElement left = wait.until(Locator.from(root).findVisible(ByTest.id("left"), index));
+ left.clear();
+ left.sendKeys(value);
+ }
+
+ public void setRightField(int index, String value){
+ WebElement right = wait.until(Locator.from(root).findVisible(ByTest.id("right"), index));
+ right.clear();
+ right.sendKeys(value);
+ }
+
+ public void selectOperator(int index, String value){
+ WebElement operatorElement = wait.until(Locator.from(root).findVisible(ByTest.id("selectOperator"), index));
+ Select operatorSelect = new Select(operatorElement);
+ operatorSelect.selectByVisibleText(value);
+ }
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/tests/SanityTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/tests/SanityTest.java
new file mode 100644
index 0000000..9f31ddd
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/tests/SanityTest.java
@@ -0,0 +1,150 @@
+package com.att.ecomp.dcae.ci.ui.rule_editor.tests;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+
+import org.openecomp.d2.ci.report.ExtentTestActions;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.testng.annotations.Test;
+
+import com.att.ecomp.dcae.ci.ui.rule_editor.BaseTest;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.HomePage;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.RuleComponent;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.RulePopup;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ActionType;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.ConcatActionComponent;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.CopyActionComponent;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.MapActionComponent;
+import com.att.ecomp.dcae.ci.ui.rule_editor.components.actions.from.RegexFromComponent;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public class SanityTest extends BaseTest {
+
+ @Test
+ public void testTranslateOfSingleCopyAction() throws Exception {
+ WebDriver driver = getDriver();
+ ExtentTestActions.log(Status.INFO, "test start");
+ List<WebElement> findElements = driver.findElements(By.cssSelector("[data-tests-id*=\"map\" i]"));
+
+
+ WebElement appElement;
+ HomePage homePage = initHomePage(driver);
+ homePage.load("5.3", "syslog");
+ setRule1(homePage.clickAddFirstRule());
+ setRule2(homePage.clickAddMoreRule(), driver);
+ RulePopup editRule1 = homePage.getRule(0).clickEdit(driver, homePage.getRoot());
+ validateRule1(editRule1);
+ editRule1 = homePage.getRule(0).clickEdit(driver, homePage.getRoot());
+ editRule1(editRule1);
+ RuleComponent firstRuleinList = verifyRuleListDescription(homePage);
+ deleteRuleFromRuleList(driver, homePage, firstRuleinList);
+ translateRuleList(driver, homePage);
+ refreshAndVerifyGetRules(driver);
+ }
+
+ private void refreshAndVerifyGetRules(WebDriver driver) {
+ Report.log(Status.INFO, "Refresh and verify getting rule list");
+ HomePage homePage;
+ RuleComponent firstRuleinList;
+ driver.navigate().refresh();
+ homePage = initHomePage(driver);
+ firstRuleinList = homePage.getRule(0);
+ assertThat(firstRuleinList.getDescription()).contains("Yanir Manor");
+ }
+
+ private void translateRuleList(WebDriver driver, HomePage homePage) throws Exception {
+ Report.log(Status.INFO, "Translate rule list");
+ homePage.clickTranslate();
+ String translation = homePage.getTranslation(driver);
+ assertThat(translation).isNotEmpty();
+ }
+
+ private void deleteRuleFromRuleList(WebDriver driver, HomePage homePage, RuleComponent firstRuleinList) {
+ Report.log(Status.INFO, "Delete the first rule from list");
+ firstRuleinList.clickDelete(driver);
+ homePage.clickOnRuleDeleteConfirmPopup();
+ }
+
+ private RuleComponent verifyRuleListDescription(HomePage homePage) {
+ Report.log(Status.INFO, "Verify Rule List Description");
+ RuleComponent firstRuleinList = homePage.getRule(0);
+ assertThat(firstRuleinList.getDescription()).contains("Oren Levi");
+ return firstRuleinList;
+ }
+
+ private HomePage initHomePage(WebDriver driver) {
+ WebElement appElement = driver.findElement(By.cssSelector("body"));
+ HomePage homePage = new HomePage(defaultTimeoutWait, appElement);
+ homePage.waitForLoaderFinish();
+ return homePage;
+ }
+
+ private void setRule1(RulePopup rulePopup) {
+ Report.log(Status.INFO, "Set first rule");
+ rulePopup.setDescription("Oren Levi");
+ CopyActionComponent copyAction = rulePopup.addCopyAction(0);
+ rulePopup.clickSave();
+ WebElement errorList = rulePopup.getErrorList();
+ assertThat(errorList.getText()).isNotEmpty();
+ rulePopup.addSimpleCondition();
+ RegexFromComponent fromComponent = copyAction.getFromComponent();
+ fromComponent.setValue("Argentina");
+ fromComponent.clickRegex();
+ fromComponent.setRegex("*");
+ copyAction.setTarget("Mexico");
+ rulePopup.clickSave();
+ }
+
+ private void validateRule1(RulePopup rulePopup) {
+ Report.log(Status.INFO, "Validate first rule");
+ assertThat(rulePopup.getDescription()).isEqualTo("Oren Levi");
+ CopyActionComponent copyAction = (CopyActionComponent) rulePopup.getAction(ActionType.Copy, 0);
+ RegexFromComponent fromComponent = copyAction.getFromComponent();
+ assertThat(fromComponent.getValue()).isEqualTo("Argentina");
+ assertThat(fromComponent.getRegex()).isEqualTo("*");
+ assertThat(copyAction.getTarget()).isEqualTo("Mexico");
+ rulePopup.clickCancel();
+ }
+
+ private void editRule1(RulePopup rulePopup) {
+ Report.log(Status.INFO, "Edit first rule");
+ CopyActionComponent copyAction = (CopyActionComponent) rulePopup.getAction(ActionType.Copy, 0);
+ RegexFromComponent fromComponent = copyAction.getFromComponent();
+ fromComponent.setValue("Brazil");
+ fromComponent.setRegex("**");
+ copyAction.setTarget("Canada");
+ rulePopup.clickSave();
+ }
+
+ private void setRule2(RulePopup rulePopup, WebDriver driver) {
+ Report.log(Status.INFO, "Set second rule");
+ rulePopup.setDescription("Yanir Manor");
+
+ Report.log(Status.INFO, "Add complex condition");
+ rulePopup.addComplexCondition();
+
+ Report.log(Status.INFO, "Add concat action");
+ ConcatActionComponent concatAction = rulePopup.addConcatAction(0);
+ concatAction.getFromComponent(0).setValue("Oren");
+ concatAction.getFromComponent(1).setValue("Levi");
+ concatAction.clickAddInput(2).setValue("yanir");
+ concatAction.getFromComponent(1).clickDelete(driver);
+ concatAction.setTargetFromTree();
+
+ Report.log(Status.INFO, "Add map action");
+ MapActionComponent mapAction = rulePopup.addMapAction(1);
+ mapAction.getFromComponent().setValue("Mapfrom");
+ mapAction.setTarget("MapTarget");
+ mapAction.openDefaultOption();
+ mapAction.setDefaultData("default data");
+ mapAction.setKeyData("A");
+ mapAction.setValueData("B");
+
+ rulePopup.clickSave();
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java
new file mode 100644
index 0000000..1f6f59a
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/setup/ConfigTest.java
@@ -0,0 +1,83 @@
+package com.att.ecomp.dcae.ci.ui.setup;
+
+import java.io.File;
+import java.util.Map;
+
+import org.openecomp.d2.ci.datatypes.Configuration;
+import org.openecomp.d2.ci.datatypes.UserCredentials;
+import org.openecomp.d2.ci.datatypes.UserRoleEnum;
+import org.openecomp.d2.ci.setup.SetupCDTest;
+import org.openecomp.d2.ci.utilities.FileHandling;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+import org.openecomp.d2.ci.utilities.LoginUtils;
+import org.openqa.selenium.WebElement;
+import org.testng.annotations.BeforeMethod;
+
+import com.att.ecomp.dcae.ci.utilities.ConfigurationReader;
+import com.att.ecomp.dcae.ci.utilities.Report;
+import com.aventstack.extentreports.Status;
+
+public abstract class ConfigTest extends SetupCDTest {
+
+ protected abstract UserRoleEnum getUserRole();
+
+ @Override
+ protected Configuration getEnvConfiguration() {
+ return ConfigurationReader.getConfiguration();
+ }
+
+ @Override
+ protected UserCredentials getUserCredentials() {
+ try {
+ String userRole = getUserRole().name().toLowerCase();
+ String credentialsFile = System.getProperty("credentials.file");
+ if (credentialsFile == null)
+ credentialsFile = ConfigurationReader.confPath() + "credentials.yaml";
+ File file = new File(credentialsFile);
+ if (!file.exists()){
+ throw new Exception("Please provide a credentails file");
+ }
+ Map<?, ?> credentialsParsedFile = FileHandling.parseYamlFile(credentialsFile);
+ Map<String, String> credentialsMap = (Map<String, String>) credentialsParsedFile.get(userRole);
+ String userId = (String) credentialsMap.get("username");
+ String password = (String) credentialsMap.get("password");
+ String firstname = (String) credentialsMap.get("firstname");
+ String lastname = (String) credentialsMap.get("lastname");
+
+ UserCredentials userCredentials = new UserCredentials(userId, password, firstname, lastname, null);
+ Report.log(Status.INFO, "Using user Credentials="+userCredentials);
+ return userCredentials;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ protected void loginToLocalSimulator(UserCredentials user) {
+ LoginUtils.loginToLocalWebsealSimulator(user);
+ }
+
+ @BeforeMethod
+ public void beforeTest(){
+ try{
+ if(getEnvConfiguration().getUrl().contains("localhost"))
+ {
+ GeneralUIUtils.ultimateWait();
+ }
+ else
+ {
+ WebElement close = GeneralUIUtils.getWebElementByClassName("sdc-welcome-close");
+ close.click();
+ GeneralUIUtils.ultimateWait();
+ }
+ }
+ catch(Exception e){
+ Report.logDebug("Exception has occured in beforeTest - unable to proceed to test ", e);
+ e.printStackTrace();
+ }
+ }
+
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/setup/DcaeConfiguration.java b/src/main/java/com/att/ecomp/dcae/ci/ui/setup/DcaeConfiguration.java
new file mode 100644
index 0000000..2eee2b4
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/setup/DcaeConfiguration.java
@@ -0,0 +1,48 @@
+package com.att.ecomp.dcae.ci.ui.setup;
+
+import org.openecomp.d2.ci.datatypes.Configuration;
+
+public class DcaeConfiguration extends Configuration {
+
+ private String apiPath;
+ private String dcaeBeHost;
+ private String dcaeBePort;
+ private String ruleEditorUrl;
+
+
+
+ public String getApiPath() {
+ return apiPath;
+ }
+
+ public void setApiPath(String apiPath) {
+ this.apiPath = apiPath;
+ }
+
+ public String getDcaeBeHost() {
+ return dcaeBeHost;
+ }
+
+ public void setDcaeBeHost(String dcaeBeHost) {
+ this.dcaeBeHost = dcaeBeHost;
+ }
+
+ public String getDcaeBePort() {
+ return dcaeBePort;
+ }
+
+ public void setDcaeBePort(String dcaeBePort) {
+ this.dcaeBePort = dcaeBePort;
+ }
+
+ public String getRuleEditorUrl() {
+ return ruleEditorUrl;
+ }
+
+ public void setRuleEditorUrl(String ruleEditorUrl) {
+ this.ruleEditorUrl = ruleEditorUrl;
+ }
+
+
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java
new file mode 100644
index 0000000..b7f2441
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/DCAESanity.java
@@ -0,0 +1,99 @@
+package com.att.ecomp.dcae.ci.ui.tests;
+
+import org.openecomp.d2.ci.datatypes.UserRoleEnum;
+import org.openecomp.d2.ci.report.ExtentTestActions;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+import org.openqa.selenium.WebElement;
+import org.testng.annotations.Test;
+import com.att.ecomp.dcae.ci.ui.pages.DCAECompositionPage;
+import com.att.ecomp.dcae.ci.ui.pages.DCAEGeneralPage;
+import com.att.ecomp.dcae.ci.ui.pages.DCAEHomePage;
+import com.att.ecomp.dcae.ci.ui.pages.DCAELeftPanel;
+import com.att.ecomp.dcae.ci.ui.pages.DCAEServicesPage;
+import com.att.ecomp.dcae.ci.ui.pages.SDCCreateServicePage;
+import com.att.ecomp.dcae.ci.ui.pages.SDCCreateVFPage;
+import com.att.ecomp.dcae.ci.ui.pages.SDCHomePage;
+import com.att.ecomp.dcae.ci.ui.setup.ConfigTest;
+import com.att.ecomp.dcae.ci.ui.tests.verificator.ServiceVerificator;
+import com.aventstack.extentreports.Status;
+
+public class DCAESanity extends ConfigTest{
+
+ @Override
+ protected UserRoleEnum getUserRole() {
+ // TODO Auto-generated method stub
+ return UserRoleEnum.DESIGNER;
+ }
+
+ @Test (description = "DCAE Main scenario", groups={"Sanity"})
+ public void sanityTestSDCSection() throws Exception
+ {
+ String vfName;
+ String serviceName;
+
+ // ------------------ SDC-Side: Create VF --------------------------
+
+ System.out.println("Start Test");
+
+ SDCHomePage.clickOnAddVf();
+ vfName = SDCCreateVFPage.addAllVFMandtoryFields("Utility"); //Creates VF, need to send only the desired category name
+ SDCCreateVFPage.clickOnCreateVFButton();
+ SDCCreateVFPage.checkInVF();
+
+ // ------------------ SDC-Side: Create Service ---------------------
+ SDCHomePage.clickOnAddsService();
+ serviceName = SDCCreateServicePage.addAllServiceMandtoryFields("Network L1-3");
+ SDCCreateServicePage.clickOnCreateServiceButton();
+ SDCCreateServicePage.clickOnServiceCompsitionTab();
+ SDCCreateServicePage.addAssetToCanvas(vfName);
+ SDCCreateServicePage.checkInService();
+
+ // ------------------ DCAE-Side: Create Asset -------------------
+
+ DCAEHomePage.clickOnDcaeTab();
+ DCAEHomePage.clickOnCreateNewAsset();
+
+ String assetName = DCAEGeneralPage.addAssetName("Asset Name");
+ DCAEGeneralPage.addAssetDescription("Asset Description");
+ DCAEGeneralPage.clickSaveAsset();
+
+ DCAELeftPanel.navigateToServices();
+
+ DCAEServicesPage.selectService(serviceName);
+ DCAEServicesPage.selectVNFI(vfName);
+ DCAEServicesPage.clickAttach(vfName);
+
+ DCAELeftPanel.navigateToComposition();
+
+ WebElement item = DCAECompositionPage.expandList("Microservice");
+ DCAECompositionPage.addItemFromList(item);
+ DCAECompositionPage.SelectFlowType("Syslog");
+ DCAECompositionPage.clickSave();
+ DCAECompositionPage.clickSubmit();
+
+ //------------------ Verify Blue Print
+
+ SDCHomePage.clickOnHomeTab();
+ SDCHomePage.searchForElement(serviceName);
+ SDCHomePage.clickOnElement(serviceName);
+ try
+ {
+ SDCCreateServicePage.clickOnServiceCompsitionTab();
+ }
+ catch(Exception e)
+ {
+ GeneralUIUtils.getDriver().navigate().refresh();
+ SDCCreateServicePage.clickOnServiceCompsitionTab();
+ ExtentTestActions.log(Status.WARNING,"SDC UI known Bug - Blank page with text: {{getStatus()}}, the browser was refreshed to bypass this bug.");
+ }
+
+ SDCCreateServicePage.clickOnElementInCanavs();
+ SDCCreateServicePage.clickOnArtifactTab();
+ ServiceVerificator.verifyBluePrintArtifactExist(assetName);
+
+ ExtentTestActions.log(Status.INFO, "Test Ended.");
+
+ System.out.println("End Test");
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/SanityTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/SanityTest.java
new file mode 100644
index 0000000..a13a12e
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/SanityTest.java
@@ -0,0 +1,108 @@
+package com.att.ecomp.dcae.ci.ui.tests;
+
+import org.openecomp.d2.ci.datatypes.Configuration;
+import org.openecomp.d2.ci.datatypes.UserCredentials;
+import org.openecomp.d2.ci.datatypes.UserRoleEnum;
+import org.openqa.selenium.WebElement;
+import org.testng.annotations.Test;
+import com.att.ecomp.dcae.ci.ui.pages.DCAECompositionPage;
+import com.att.ecomp.dcae.ci.ui.pages.DCAEGeneralPage;
+import com.att.ecomp.dcae.ci.ui.pages.DCAEHomePage;
+import com.att.ecomp.dcae.ci.ui.pages.DCAELeftPanel;
+import com.att.ecomp.dcae.ci.ui.pages.DCAEServicesPage;
+import com.att.ecomp.dcae.ci.ui.pages.SDCCreateServicePage;
+import com.att.ecomp.dcae.ci.ui.pages.SDCCreateVFPage;
+import com.att.ecomp.dcae.ci.ui.pages.SDCHomePage;
+import com.att.ecomp.dcae.ci.ui.setup.ConfigTest;
+
+public class SanityTest extends ConfigTest{
+
+
+ public Configuration configuration = ConfigTest.getConfiguration();
+
+
+ @Override
+ protected UserRoleEnum getUserRole() {
+ return UserRoleEnum.DESIGNER;
+ }
+
+
+ // Only when running locally
+ @Override
+ public void navigateAndLogin(UserCredentials userCredentials) throws Exception {
+
+ navigateToUrl(configuration.getUrl());
+ }
+
+
+ @Test (description = "DCAE Main scenario", groups={"Sanity"})
+ public void sanityTestDCAESection() throws InterruptedException{
+
+ //HomePage.clickOnDcaeTab(); // not needed on local
+
+
+
+
+
+
+
+ ////------TO DELETE
+ String vfName;
+ String serviceName;
+
+ // ------------------ SDC-Side: Create VF --------------------------
+
+ System.out.println("Start Test");
+
+ SDCCreateServicePage.clickOnElementInCanavs();
+
+ SDCHomePage.clickOnAddVf();
+ vfName = SDCCreateVFPage.addAllVFMandtoryFields("Microservice"); //Creates VF, need to send only the desired category name
+ SDCCreateVFPage.clickOnCreateVFButton();
+ SDCCreateVFPage.checkInVF();
+
+ // ------------------ SDC-Side: Create Service ---------------------
+ SDCHomePage.clickOnAddsService();
+ serviceName = SDCCreateServicePage.addAllServiceMandtoryFields("Network L1-3");
+ SDCCreateServicePage.clickOnCreateServiceButton();
+ SDCCreateServicePage.clickOnServiceCompsitionTab();
+ SDCCreateServicePage.addAssetToCanvas(vfName);
+ SDCCreateServicePage.checkInService();
+
+
+ ////------TO DELETE
+
+
+
+
+
+
+
+
+
+
+ System.out.println("Start Test");
+
+ DCAEHomePage.clickOnCreateNewAsset();
+
+ DCAEGeneralPage.addAssetName("Asset Name");
+ DCAEGeneralPage.addAssetDescription("Asset Description");
+// DCAEGeneralPage.clickSaveAsset();
+
+ DCAELeftPanel.navigateToServices();
+
+ DCAEServicesPage.selectService("Servicedbb463a1-50bb-4aef-b84c-8c2bb9a8f866");
+ DCAEServicesPage.selectVNFI("VF30ca7676-35c5-4c3c-9cc8-a06c23b17872");
+ DCAEServicesPage.clickAttach("VF30ca7676-35c5-4c3c-9cc8-a06c23b17872");
+
+ DCAELeftPanel.navigateToComposition();
+
+ WebElement item = DCAECompositionPage.expandList("Microservice");
+ DCAECompositionPage.addItemFromList(item);
+ DCAECompositionPage.clickSave();
+ DCAECompositionPage.clickSubmit();
+
+ System.out.println("End Test");
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/ServiceTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/ServiceTest.java
new file mode 100644
index 0000000..bc99033
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/ServiceTest.java
@@ -0,0 +1,42 @@
+package com.att.ecomp.dcae.ci.ui.tests;
+
+import java.util.UUID;
+
+import org.openecomp.d2.ci.datatypes.UserRoleEnum;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+import org.openqa.selenium.WebElement;
+import org.testng.annotations.Test;
+
+import com.att.ecomp.dcae.ci.ui.pages.DCAEHomePage;
+import com.att.ecomp.dcae.ci.ui.setup.ConfigTest;
+
+public class ServiceTest extends ConfigTest {
+
+ @Override
+ protected UserRoleEnum getUserRole() {
+ return UserRoleEnum.DESIGNER;
+ }
+
+ @Test
+ public void createServiceTest(){
+ DCAEHomePage.clickOnDcaeTab();
+
+ GeneralUIUtils.hoverOnAreaByTestId("AddButtonsArea");
+ GeneralUIUtils.findByText("Add Service Assurance Template").click();
+ GeneralUIUtils.ultimateWait();
+
+ WebElement nameTextbox = GeneralUIUtils.getWebElementByTestID("name");
+ nameTextbox.clear();
+ nameTextbox.sendKeys("autoServicer" + UUID.randomUUID());
+
+ WebElement descriptionTextbox = GeneralUIUtils.getWebElementByTestID("description");
+ descriptionTextbox.clear();
+ descriptionTextbox.sendKeys("new service");
+
+ GeneralUIUtils.findByText("Create").click();
+ GeneralUIUtils.ultimateWait();
+ }
+
+
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/CompositionVerificator.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/CompositionVerificator.java
new file mode 100644
index 0000000..59faa2a
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/CompositionVerificator.java
@@ -0,0 +1,16 @@
+package com.att.ecomp.dcae.ci.ui.tests.verificator;
+
+import static org.testng.Assert.assertTrue;
+
+public class CompositionVerificator {
+
+ public static void verifySaveSuccessfully(String actualSaveRes)
+ {
+ assertTrue(actualSaveRes.startsWith("Composition Created"));
+ }
+
+ public static void verifySubmitSuccessfully(String actualSubmitRes) {
+ assertTrue(actualSubmitRes.equalsIgnoreCase("Blueprint Created"));
+
+ }
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/ServiceVerificator.java b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/ServiceVerificator.java
new file mode 100644
index 0000000..99957cf
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/tests/verificator/ServiceVerificator.java
@@ -0,0 +1,22 @@
+package com.att.ecomp.dcae.ci.ui.tests.verificator;
+
+import org.openecomp.d2.ci.report.ExtentTestActions;
+import org.openecomp.d2.ci.utilities.GeneralUIUtils;
+
+import com.aventstack.extentreports.Status;
+
+import static org.testng.Assert.assertTrue;
+
+public class ServiceVerificator
+{
+ public static void verifyBluePrintArtifactExist(String name)
+ {
+ ExtentTestActions.log(Status.INFO,"Verifying Blue Print artifact exist");
+ String artifactName = "Foi" + "." + name.replaceAll("\\s+","").replaceAll("-", "") + ".event_proc_bp.yaml";
+ GeneralUIUtils.waitForElementInVisibilityByTestId("artifactName-blueprint-foi");
+ String actualBluePrintFileName = GeneralUIUtils.getWebElementByTestID("artifactName-blueprint-foi").getText();
+ assertTrue(artifactName.equalsIgnoreCase(actualBluePrintFileName));
+ ExtentTestActions.log(Status.INFO, String.format("Actual Blue print file name is: %s.", actualBluePrintFileName));
+ GeneralUIUtils.ultimateWait();
+ }
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/ByTest.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/ByTest.java
new file mode 100644
index 0000000..ab59b28
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/ByTest.java
@@ -0,0 +1,17 @@
+package com.att.ecomp.dcae.ci.ui.utils;
+
+import org.openqa.selenium.By.ByCssSelector;
+
+public class ByTest extends ByCssSelector {
+
+ private static final long serialVersionUID = 7435597710732625685L; // auto generated - does nothing
+
+ protected ByTest(String cssSelector) {
+ super(cssSelector);
+ }
+
+ public static ByTest id(String id) {
+ return new ByTest(String.format("[data-tests-id=\"%s\"]", id));
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/Locator.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/Locator.java
new file mode 100644
index 0000000..7e625d5
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/Locator.java
@@ -0,0 +1,74 @@
+package com.att.ecomp.dcae.ci.ui.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+public class Locator {
+
+ private WebElement element;
+
+ private Locator(WebElement element) {
+ this.element = element;
+ }
+
+ public static Locator from(WebElement element) {
+ return new Locator(element);
+ }
+
+ public ExpectedCondition<WebElement> find(By by, int index) {
+ return new NestedFinder(this.element, by) {
+ @Override
+ protected WebElement predicate(List<WebElement> elements) {
+ return (elements.size() > index) ? elements.get(index) : null;
+ }
+
+ @Override
+ public String toString() {
+ return "element located by " + by;
+ }
+ };
+ }
+
+ public ExpectedCondition<WebElement> findVisible(By by, int index) {
+ return new NestedFinder(this.element, by) {
+ @Override
+ protected WebElement predicate(List<WebElement> elements) {
+ return visibleElementsOrNull(elements, index);
+ }
+
+ @Override
+ public String toString() {
+ return "visibility of element located by " + by;
+ }
+ };
+ }
+
+ public ExpectedCondition<List<WebElement>> findNoVisible(By by) {
+ return new NestedFilter(this.element, by) {
+ @Override
+ protected List<WebElement> predicate(List<WebElement> elements) {
+ WebElement visible = visibleElementsOrNull(elements, 0);
+ return (visible != null) ? null : new ArrayList<WebElement>();
+ }
+
+ @Override
+ public String toString() {
+ return "no visible elements located by " + by;
+ }
+ };
+ }
+
+ private static WebElement visibleElementsOrNull(List<WebElement> elements, int index) {
+ List<WebElement> visibles = elements.stream()
+ .filter(elem -> elem.isDisplayed())
+ .collect(Collectors.toList());
+ return (visibles.size() > index) ? visibles.get(index) : null;
+ }
+
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFilter.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFilter.java
new file mode 100644
index 0000000..925fea5
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFilter.java
@@ -0,0 +1,28 @@
+package com.att.ecomp.dcae.ci.ui.utils;
+
+import java.util.List;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+public abstract class NestedFilter implements ExpectedCondition<List<WebElement>> {
+
+ private WebElement parent;
+ private By by;
+
+ public NestedFilter(WebElement parent, By by) {
+ this.parent = parent;
+ this.by = by;
+ }
+
+ abstract protected List<WebElement> predicate(List<WebElement> elements);
+
+ @Override
+ public List<WebElement> apply(WebDriver input) {
+ List<WebElement> elements = parent.findElements(by);
+ return predicate(elements);
+ }
+
+}
diff --git a/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFinder.java b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFinder.java
new file mode 100644
index 0000000..ead2bef
--- /dev/null
+++ b/src/main/java/com/att/ecomp/dcae/ci/ui/utils/NestedFinder.java
@@ -0,0 +1,28 @@
+package com.att.ecomp.dcae.ci.ui.utils;
+
+import java.util.List;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+public abstract class NestedFinder implements ExpectedCondition<WebElement> {
+
+ private WebElement parent;
+ private By by;
+
+ public NestedFinder(WebElement parent, By by) {
+ this.parent = parent;
+ this.by = by;
+ }
+
+ abstract protected WebElement predicate(List<WebElement> elements);
+
+ @Override
+ public WebElement apply(WebDriver input) {
+ List<WebElement> elements = parent.findElements(by);
+ return predicate(elements);
+ }
+
+}