diff options
Diffstat (limited to 'ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java')
-rw-r--r-- | ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java | 809 |
1 files changed, 24 insertions, 785 deletions
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java index 1ce5455dab..916b58a834 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java @@ -20,32 +20,17 @@ package org.openecomp.sdc.ci.tests.utilities; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.awt.AWTException; -import java.awt.Robot; -import java.awt.event.KeyEvent; -import java.io.File; -import java.util.Arrays; -import java.util.List; -import java.util.Random; - +import com.aventstack.extentreports.Status; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.http.HttpStatus; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.CheckBoxStatusEnum; import org.openecomp.sdc.ci.tests.datatypes.CreateAndImportButtonsEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.Dashboard; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.StepsEnum; -import org.openecomp.sdc.ci.tests.datatypes.ResourceCategoriesNameEnum; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; @@ -57,9 +42,10 @@ 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 org.testng.AssertJUnit; -import com.aventstack.extentreports.Status; +import java.io.File; +import java.util.List; +import java.util.Random; public final class ResourceUIUtils { public static final String RESOURCE_NAME_PREFIX = "ResourceCDTest-"; @@ -73,36 +59,6 @@ public final class ResourceUIUtils { static WebDriver driver = GeneralUIUtils.getDriver(); - public static void defineResourceName(String resourceName) { - - WebElement resourceNameTextbox = GeneralUIUtils.getDriver().findElement(By.name("componentName")); - resourceNameTextbox.clear(); - resourceNameTextbox.sendKeys(resourceName); - } - - public static void defineResourceCategory(String category, String datatestsid) { - - GeneralUIUtils.getSelectList(category, datatestsid); - } - - // public static void uploadFileWithJavaRobot(String FilePath,String - // FileName) throws Exception{ - // - // StringSelection Path= new StringSelection(FilePath+FileName); - // Thread.sleep(1000); - // java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(Path, - // null); - // Robot robot = new Robot(); - // robot.delay(1000); - // robot.keyPress(KeyEvent.VK_CONTROL); - // robot.keyPress(KeyEvent.VK_V); - // robot.keyRelease(KeyEvent.VK_V); - // robot.keyRelease(KeyEvent.VK_CONTROL); - // robot.delay(1000); - // robot.keyPress(KeyEvent.VK_ENTER); - // robot.keyRelease(KeyEvent.VK_ENTER); - // robot.delay(1000); - // } // click and upload tosca file //**to be changed. public static void importFileWithSendKey(String FilePath, String FileName, CreateAndImportButtonsEnum type) throws Exception { @@ -110,33 +66,6 @@ public final class ResourceUIUtils { importButton.sendKeys(FilePath + FileName); } - public static void importFileWithSendKeyBrowse(String FilePath, String FileName) throws Exception { - WebElement browsebutton = GeneralUIUtils.getWebElementByTestID("browseButton"); - browsebutton.sendKeys(FilePath + FileName); - } - - // public static void defineVendorName(String resourceVendorName) { - // - // WebElement resourceVendorNameTextbox = - // GeneralUIUtils.getWebElementByTestID("vendorName"); - // resourceVendorNameTextbox.clear(); - // resourceVendorNameTextbox.sendKeys(resourceVendorName); - // } - - // public static void defineTagsList(ResourceReqDetails resource,String - // []resourceTags) { - // List<String>taglist = new ArrayList<String>();; - // WebElement resourceTagsTextbox = - // GeneralUIUtils.getWebElementByTestID("i-sdc-tag-input"); - // for (String tag : resourceTags) { - // resourceTagsTextbox.clear(); - // resourceTagsTextbox.sendKeys(tag); - // resourceTagsTextbox.sendKeys(Keys.ENTER); - // taglist.add(tag); - // } - // resource.setTags(taglist); - // } - public static String defineUserId(String userId) { // WebElement resourceUserIdTextbox = ResourceGeneralPage.getContactIdField(); @@ -145,19 +74,6 @@ public final class ResourceUIUtils { return userId; } - public static void defineVendorRelease(String resourceVendorRelease) { - - WebElement resourceVendorReleaseTextbox = GeneralUIUtils.getWebElementByTestID("vendorRelease"); - resourceVendorReleaseTextbox.clear(); - resourceVendorReleaseTextbox.sendKeys(resourceVendorRelease); - } - - public static void selectResourceIcon(String resourceIcon) throws Exception { - WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 10); - wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@data-tests-id='" + resourceIcon + "']"))) - .click(); - } - public static String definePropertyName(String name) { WebElement nameProperty = GeneralUIUtils.getDriver().findElement(By.name("propertyName")); @@ -174,51 +90,6 @@ public final class ResourceUIUtils { iconElement.get(0).click(); } - public static List<WebElement> getAllObjectsOnWorkspace(WebDriver driver, ResourceReqDetails resource) - throws Exception { - - WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 10); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@*='" + resource.getName() + "']"))); - return GeneralUIUtils.getDriver() - .findElements(By.xpath("//div[@class='" + "w-sdc-dashboard-card-info-name" + "']")); - - } - - public static String getErrorMessageText(String text) throws Exception { - - return GeneralUIUtils.getWebElementByClassName(text).getText(); - - } - - public static WebElement scrollElement(WebDriver driver) throws Exception { - - return GeneralUIUtils.getDriver().findElement(By.className("ps-scrollbar-y")); - } - - public static void scrollDownPage() throws AWTException, InterruptedException { - Robot robot = new Robot(); - robot.keyPress(KeyEvent.VK_PAGE_DOWN); - robot.keyRelease(KeyEvent.VK_PAGE_DOWN); - robot.keyPress(KeyEvent.VK_PAGE_DOWN); - robot.keyRelease(KeyEvent.VK_PAGE_DOWN); - robot.keyPress(KeyEvent.VK_PAGE_DOWN); - robot.keyRelease(KeyEvent.VK_PAGE_DOWN); - robot.keyPress(KeyEvent.VK_PAGE_DOWN); - robot.keyRelease(KeyEvent.VK_PAGE_DOWN); - robot.keyPress(KeyEvent.VK_PAGE_DOWN); - robot.keyRelease(KeyEvent.VK_PAGE_DOWN); - robot.keyPress(KeyEvent.VK_PAGE_DOWN); - robot.keyRelease(KeyEvent.VK_PAGE_DOWN); - robot.keyPress(KeyEvent.VK_PAGE_DOWN); - robot.keyRelease(KeyEvent.VK_PAGE_DOWN); - } - - public static void defineNewSelectList(String Text) { - WebElement mySelectElm = GeneralUIUtils.getDriver().findElement(By.className("i-sdc-form-select")); - Select mySelectString = new Select(mySelectElm); - mySelectString.selectByVisibleText(Text); - } - public static void defineDefaultValueByType(String Value) { WebElement valueString = GeneralUIUtils.getDriver().findElement(By.name("value")); @@ -233,61 +104,6 @@ public final class ResourceUIUtils { se.selectByValue(Value); } - public static void clickButtonBlue() { - WebElement clickButtonBlue = GeneralUIUtils.getDriver().findElement(By.className("w-sdc-btn-blue")); - clickButtonBlue.click(); - } - - public static void clickButton(String selectButton) { - - WebElement clickButton = GeneralUIUtils.getDriver() - .findElement(By.xpath("//*[@data-tests-id='" + selectButton + "']")); - clickButton.click(); - } - - public static WebElement Waitfunctionforbuttons(String element, int timeout) { - WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), timeout); - return wait.until(ExpectedConditions.elementToBeClickable(By.xpath(element))); - } - - public static WebElement waitToButtonSubmitForTesting() { - return Waitfunctionforbuttons("//*[@data-tests-id='submitForTesting']", 10); - } - - public static WebElement waitToFinishButtonEnabled() { - return Waitfunctionforbuttons("//button[@data-tests-id='Finish']", 10); - } - - public static WebElement waitToNextButtonEnabled() { - return Waitfunctionforbuttons("//button[@data-tests-id='Next']", 10); - } - - public static WebElement waitToHomeMenu() { - return Waitfunctionforbuttons("//*[@data-tests-id='main-menu-button-home']", 10); - } - - public static WebElement waitToCatalogMenu() { - return Waitfunctionforbuttons("//*[@data-tests-id='main-menu-button-catalog']", 10); - } - - public static WebElement waitSearch() { - return Waitfunctionforbuttons("//*[@data-tests-id='main-menu-input-search']", 10); - } - - public static WebElement waitSubmitforTestingCard() { - return Waitfunctionforbuttons("//*[@data-tests-id='i-sdc-dashboard-card-menu-item-SubmitforTesting']", 10); - } - - public static WebElement waitViewCard() { - return Waitfunctionforbuttons("//*[@data-tests-id='i-sdc-dashboard-card-menu-item-View']", 5); - } - -// public static void waitOpenCard(String requiredElementUniqueId) throws Exception { -// WebElement menu = GeneralUIUtils.getDriver() -// .findElement(By.xpath("//*[@data-tests-id='" + requiredElementUniqueId + "']")); -// GeneralUIUtils.hoverOnAreaByTestId(menu); -// } - public static void fillResourceGeneralInformationPage(ResourceReqDetails resource, User user, boolean isNewResource) { try { ResourceGeneralPage.defineName(resource.getName()); @@ -313,11 +129,6 @@ public final class ResourceUIUtils { ResourceGeneralPage.defineDescriptionWithPaste(); ResourceGeneralPage.defineVendorNameWithPaste(); ResourceGeneralPage.defineVendorReleaseWithPaste(); -// ResourceGeneralPage.defineName(buildStringFromPattern(stringPattern, 5000)); -// ResourceGeneralPage.defineDescription(buildStringFromPattern(stringPattern, 5000)); -// ResourceGeneralPage.defineVendorName(buildStringFromPattern(stringPattern, 5000)); -// ResourceGeneralPage.defineVendorRelease(buildStringFromPattern(stringPattern, 5000)); -// ResourceGeneralPage.defineTagsList(resource, new String[] { buildStringFromPattern(stringPattern, 5000) }); ResourceGeneralPage.defineTagsListWithPaste(); GeneralUIUtils.waitForAngular(); } @@ -333,209 +144,6 @@ public final class ResourceUIUtils { return sb.toString(); } - public static void fillNewResourceValues(ResourceReqDetails resource, User user) throws Exception { - fillResourceGeneralInformationPage(resource, user, true); - GeneralPageElements.clickCreateButton(); - // selectIcon(); - } - - // coded by teddy. - - public static WebElement waitfunctionforallelements(String element) { - WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 5); - return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@*='" + element + "']"))); - } - - public static WebElement waitFunctionForaGetElements(String element, int timeout) { - WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), timeout); - return wait.until( - ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + element + "']"))); - } - - public static void getVFCGeneralInfo(ResourceReqDetails resource, User user) throws InterruptedException { - Thread.sleep(2000); - String version = GeneralUIUtils.getWebElementsListByTestID("versionvalue").get(0).getText().substring(1); - String name = GeneralUIUtils.getWebElementByTestID("name").getAttribute("value"); - String description = GeneralUIUtils.getWebElementByTestID("description").getAttribute("value"); - String category = GeneralUIUtils.getSelectList(null, "selectGeneralCategory").getFirstSelectedOption() - .getText(); - String vendorName = GeneralUIUtils.getWebElementByTestID("vendorName").getAttribute("value"); - String vendorRelease = GeneralUIUtils.getWebElementByTestID("vendorRelease").getAttribute("value"); - List<WebElement> tags = GeneralUIUtils.getWebElementsListByTestID("i-sdc-tag-text"); - String type = GeneralUIUtils.getWebElementsListByTestID("type").get(1).getText(); - int index = type.lastIndexOf(":"); - System.out.println(type.substring(0, index)); - String AttContact = GeneralUIUtils.getWebElementByTestID("attContact").getAttribute("value"); - System.out.println(resource.getVersion()); - assertTrue(resource.getVersion().equals(version)); - assertTrue(resource.getName().equals(name)); - assertTrue(resource.getDescription().equals(description)); - System.out.println(resource.getVendorName()); - System.out.println(resource.getVendorRelease()); - assertTrue(resource.getCategories().get(0).getSubcategories().get(0).getName().equals(category)); - assertTrue(resource.getVendorName().equals(vendorName)); - assertTrue(resource.getVendorRelease().equals(vendorRelease)); - assertTrue(resource.getCreatorUserId().equals(AttContact)); - assertEquals(type.substring(0, index), resource.getResourceType()); - - for (int i = 0; i < tags.size(); i++) { - assertEquals(resource.getTags().get(i), tags.get(i).getText()); - } - } - - public static void getGeneralInfo(ResourceReqDetails resource, User user) { - - // clickMore(); - // String - // componentType=waitFunctionForaGetElements("componentType",3).getText(); - // String version=waitFunctionForaGetElements("version",3).getText(); - // String - // category=waitFunctionForaGetElements("category",3).getText();//get - // right panel Category. - // String - // resourceType=waitFunctionForaGetElements("resourceType",3).getText();//get - // right panel SubCategory. - // String date=waitfunctionforelements("creationDate",3).getText(); - // String aouthor=waitfunctionforallelements("author'",3).getText(); - // String - // vendorName=waitFunctionForaGetElements("vendorName",3).getText(); - // String - // vendorRelease=waitFunctionForaGetElements("vendorRelease",3).getText(); - // String - // AttContact=waitFunctionForaGetElements("attContact",3).getText(); - // String - // Description=waitFunctionForaGetElements("description",3).getText(); - List<WebElement> tags = GeneralUIUtils.getWebElementsListByTestID("tag"); - // // String TagVF=waitFunctionForaGetElements("tag",3).getText(); - // assertTrue(componentType.equals("RESOURCE")); - // assertTrue(version.equals(resource.getVersion())); - // assertTrue(category.equals(resource.getCategories().get(0).getName())); - // assertEquals(resourceType,resource.getResourceType()); - // // assertEquals(Date,resource.getCreationDate()); - // // assertEquals(Aouthor,resource.getCreatorFullName()); - // assertTrue(vendorName.equals(resource.getVendorName())); - // assertTrue(vendorRelease.equals(resource.getVendorRelease())); - // assertTrue(AttContact.equals(resource.getAttContact())); - // assertTrue(Description.equals(resource.getDescription()+"\nLess")); - for (WebElement tag : tags) { - System.out.println(resource.getTags().get(0)); - } - } - - public static void getGeneralInfoForTags(ResourceReqDetails resource, User user) { - - clickMore(); - String componentType = waitFunctionForaGetElements("componentType", 3).getText(); - String version = waitFunctionForaGetElements("version", 3).getText(); - String category = waitFunctionForaGetElements("category", 3).getText();// get - // right - // panel - // Category. - String resourceType = waitFunctionForaGetElements("resourceType", 3).getText();// get - // right - // panel - // SubCategory. - String date = GeneralUIUtils.getWebElementByClassName("creationDate").getText(); - String aouthor = waitfunctionforallelements("author'").getText(); - String vendorName = waitFunctionForaGetElements("vendorName", 3).getText(); - String vendorRelease = waitFunctionForaGetElements("vendorRelease", 3).getText(); - String attContact = waitFunctionForaGetElements("attContact", 3).getText(); - String description = waitFunctionForaGetElements("description", 3).getText(); - List<WebElement> tags = GeneralUIUtils.getWebElementsListByTestID("tag"); - assertTrue(componentType.equals("RESOURCE")); - assertTrue(version.equals(resource.getVersion())); - assertTrue(category.equals(resource.getCategories().get(0).getName())); - assertEquals(resourceType, resource.getResourceType()); - // assertEquals(Date,resource.getCreationDate()); - // assertEquals(Aouthor,resource.getCreatorFullName()); - assertTrue(vendorName.equals(resource.getVendorName())); - assertTrue(vendorRelease.equals(resource.getVendorRelease())); - assertTrue(attContact.equals(resource.getContactId())); - assertTrue(description.equals(resource.getDescription() + "\nLess")); - assertTrue(tags.equals("Tag-150")); - } - - public static WebElement searchVFNameInWorkspace(ResourceReqDetails resource, User user) throws Exception { - - List<WebElement> findElements = GeneralUIUtils.getDriver() - .findElements(By.xpath("//div[@data-tests-id='" + resource.getUniqueId() + "']")); - assertNotNull("did not find any elements", findElements); - for (WebElement webElement : findElements) { - if (webElement.getText().contains(resource.getUniqueId())) { - System.out.println("I find it"); - return webElement; - } - } - return null; - } - - public static Boolean searchCheckOutWorkspace(ResourceReqDetails resource, User user, - CheckBoxStatusEnum checkBoxStatusEnum) throws Exception { - - List<WebElement> findElements = GeneralUIUtils.getDriver() - .findElements(By.xpath("//div[@data-tests-id='component.lifecycleState']")); - assertNotNull("did not find any elements", findElements); - for (WebElement webElement : findElements) { - if (!webElement.getAttribute("class").contains(checkBoxStatusEnum.name())) { - return false; - } - } - return true; - } - - // coded by tedy. - public static void validateWithRightPalett(ResourceReqDetails resource, User user) { - // String - // Type=Waitfunctionforallelements("sharingService.selectedEntity.getTypeForView()",3).getText(); - String ResourceType = waitfunctionforallelements("selectedComponent.resourceType").getText(); - System.out.println(ResourceType); - String Version = waitfunctionforallelements("selectedComponent.version").getText(); - String Category = waitfunctionforallelements("selectedComponent.categories[0].name").getText();// get - // right - // panel - // Category. - String CanvasSubCategory = waitfunctionforallelements("selectedComponent.categories[0].subcategories[0].name") - .getText();// get right panel SubCategory. - // String Date=Waitfunctionforelements("selectedComponent.creationDate | - // date: 'MM/dd/yyyy'").getText(); - // String - // Aouthor=waitfunctionforallelements("selectedComponent.creatorFullName'").getText(); - String VendorName = waitfunctionforallelements("selectedComponent.vendorName").getText(); - String VendorRelease = waitfunctionforallelements("selectedComponent.vendorRelease").getText(); - String AttContact = waitfunctionforallelements("selectedComponent.attContact").getText(); - String Description = waitfunctionforallelements("selectedComponent.description").getText(); - String TagVF = waitfunctionforallelements("tag").getText(); - AssertJUnit.assertEquals(ResourceType, resource.getResourceType()); - AssertJUnit.assertEquals(Version, resource.getVersion()); - AssertJUnit.assertEquals(Category, resource.getCategories().get(0).getName()); - AssertJUnit.assertEquals(CanvasSubCategory, - resource.getCategories().get(0).getSubcategories().get(0).getName()); - // assertEquals(Date,resource.getCreationDate()); - // assertEquals(Aouthor,resource.getCreatorFullName()); - AssertJUnit.assertEquals(VendorName, resource.getVendorName()); - AssertJUnit.assertEquals(VendorRelease, resource.getVendorRelease()); - AssertJUnit.assertEquals(AttContact, resource.getContactId()); - AssertJUnit.assertEquals(Description, resource.getDescription() + "\nLess"); - AssertJUnit.assertEquals(TagVF, "qa123"); - } - - public static void clickMore() { - WebElement clickButtonSubmit = GeneralUIUtils.getDriver() - .findElement(By.className("ellipsis-directive-more-less")); - clickButtonSubmit.click(); - } - - public static RestResponse createResourceInUI(ResourceReqDetails resource, User user) - throws Exception, AWTException { - System.out.println("creating resource..."); - fillNewResourceValues(resource, user); - RestResponse getCreatedResource = RestCDUtils.getResource(resource, user); - AssertJUnit.assertEquals("Did not succeed to get any resource", HttpStatus.SC_OK, - getCreatedResource.getErrorCode().intValue()); - - return getCreatedResource; - } - /** * @deprecated Use {@link #createVF(ResourceReqDetails,User)} instead */ @@ -549,7 +157,7 @@ public final class ResourceUIUtils { } public static void createResource(ResourceReqDetails resource, User user, DataTestIdEnum.Dashboard button) { - WebElement addVFButton = null; + WebElement addVFButton; try { GeneralUIUtils.ultimateWait(); try{ @@ -585,209 +193,6 @@ public final class ResourceUIUtils { ResourceGeneralPage.clickUpdateButton(); } - - - public static RestResponse updateResourceInformationPage(ResourceReqDetails resource, User user) - throws Exception, AWTException { - - fillResourceGeneralInformationPage(resource, user, true); - GeneralPageElements.clickCreateButton(); - return null; - - } - - public static RestResponse checkInResourceInUI(ResourceReqDetails resource, User user) throws Exception { - - WebElement ASDCLink = GeneralUIUtils.getDriver().findElement(By.className("w-sdc-header-logo-link")); - ASDCLink.click(); - Thread.sleep(2000); - - List<WebElement> listFormInput = GeneralUIUtils.getDriver() - .findElements(By.className("i-sdc-left-sidebar-nav-item")); - WebElement addPropertyElement = listFormInput.get(0); - addPropertyElement.click(); - Thread.sleep(2000); - - WebElement searchResource = GeneralUIUtils.getDriver() - .findElement(By.className("w-sdc-header-catalog-search-input")); - searchResource.sendKeys("newresource4test"); - - Thread.sleep(1000); - - WebElement buttonClickMenu = GeneralUIUtils.getDriver() - .findElement(By.className("w-sdc-dashboard-card-menu-button")); - buttonClickMenu.click(); - - WebElement clickMenu = GeneralUIUtils.getDriver().findElement(By.className("w-sdc-dashboard-card-menu")); - clickMenu.click(); - - List<WebElement> clickCheckIn = GeneralUIUtils.getDriver() - .findElements(By.className("i-sdc-dashboard-card-menu-item")); - WebElement clickCheckInMenu = clickCheckIn.get(1); - clickCheckInMenu.click(); - - WebElement descriptionForSubmit = GeneralUIUtils.getDriver() - .findElement(By.className("w-sdc-modal-body-comment")); - descriptionForSubmit.sendKeys("checkin resource"); - Thread.sleep(2000); - WebElement clickButtonSubmitTwo = GeneralUIUtils.getDriver().findElement(By.className("w-sdc-btn-blue")); - clickButtonSubmitTwo.click(); - Thread.sleep(2000); - - WebElement buttonClickMenu1 = GeneralUIUtils.getDriver() - .findElement(By.className("w-sdc-dashboard-card-menu-button")); - buttonClickMenu1.click(); - - WebElement clickMenu1 = GeneralUIUtils.getDriver().findElement(By.className("w-sdc-dashboard-card-menu")); - clickMenu1.click(); - - List<WebElement> clickCheckOut = GeneralUIUtils.getDriver() - .findElements(By.className("i-sdc-dashboard-card-menu-item")); - WebElement clickCheckOutMenu = clickCheckOut.get(0); - clickCheckOutMenu.click(); - - Thread.sleep(3000); - RestResponse getResource = RestCDUtils.getResource(resource, user); - AssertJUnit.assertEquals("Did not succeed to get resource after create", 200, - getResource.getErrorCode().intValue()); - return getResource; - - } - - public static String lifeCycleStateUI() throws InterruptedException { - return GeneralUIUtils.getWebElementByTestID("formlifecyclestate").getText(); - } - - public static List<String> catalogFilterResourceCategoriesChecBox(ResourceCategoriesNameEnum enumName) - throws Exception { - List<String> categories = Arrays.asList(); - switch (enumName) { - case APPLICATIONL4: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("applicationServer", "defaulticon", "vl", "cp", "call_controll", "borderElement", - "network", "firewall", "database", "loadBalancer"); - break; - case APPLICATION_SERVER: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("applicationServer", "vl", "cp", "defaulticon"); - break; - case BORDER_ELEMENT: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("borderElement", "vl", "cp", "defaulticon"); - break; - case CALL_CONTROL: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("call_controll", "vl", "cp", "defaulticon"); - break; - case COMMON_NETWORK_RESOURCES: - GeneralUIUtils.getWebElementByLinkText("Common Network Resources").click(); - categories = Arrays.asList("network", "vl", "cp", "defaulticon"); - break; - case CONNECTION_POINTS: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("cp", "defaulticon"); - break; - case DATABASE: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("database", "vl", "cp", "defaulticon"); - break; - case DATABASE_GENERIC: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("database", "vl", "cp", "defaulticon"); - break; - case FIREWALL: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("firewall", "vl", "cp", "defaulticon"); - break; - case GATEWAY: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("gateway", "vl", "cp", "defaulticon"); - break; - case INFRASTRUCTURE: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("connector", "vl", "cp", "defaulticon"); - break; - case INFRASTRUCTUREL23: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("ucpe", "vl", "cp", "defaulticon"); - break; - case LAN_CONNECTORS: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("network", "port", "connector", "vl", "cp", "defaulticon"); - break; - case LOAD_BALANCER: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("loadBalancer", "vl", "cp", "defaulticon"); - break; - case MEDIA_SERVERS: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("network", "vl", "cp", "defaulticon"); - break; - case NETWORKL4: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("network", "vl", "cp", "defaulticon"); - break; - case NETWORK_ELEMENTS: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("port", "defaulticon", "network", "connector", "vl", "cp"); - break; - case NETWORK_L23: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("network", "vl", "defaulticon", "cp", "router", "port", "connector", "gateway", - "ucpe"); - break; - case NETWORK_CONNECTIVITY: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("network", "vl", "cp", "defaulticon"); - break; - case GENERIC: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("database", "port", "loadBalancer", "vl", "cp", "objectStorage", "compute", - "defaulticon", "ucpe", "network", "connector"); - break; - case ABSTRACT: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("objectStorage", "compute", "defaulticon", "cp", "vl"); - break; - case Router: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("router", "vl", "cp", "defaulticon"); - break; - case VIRTUAL_LINKS: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("vl", "defaulticon"); - break; - case WAN_Connectors: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("network", "port", "connector", "vl", "cp", "defaulticon"); - break; - case WEB_SERVER: - GeneralUIUtils.getWebElementByTestID(enumName.getValue()).click(); - categories = Arrays.asList("applicationServer", "vl", "cp", "defaulticon"); - break; - } - return categories; - } - - public static void deleteVersionInUI() throws Exception { - - waitToDeleteVersion().click(); - ResourceUIUtils.clickButtonBlue(); - } - - public static void selectTabInRightPallete(String className) throws Exception { - WebElement tab = GeneralUIUtils.getWebElementByClassName(className); - tab.click(); - } - - public static WebElement waitToDeleteVersion() { - return Waitfunctionforbuttons("//*[@data-tests-id='deleteVersion']", 10); - } - - public static WebElement rihtPanelAPI() { - return waitFunctionForaGetElements("tab-api", 10); - } - /** * Click on HTML element. * @@ -808,55 +213,6 @@ public final class ResourceUIUtils { } /** - * Move to HTML element by class name. When moving to the HTML element, it - * will raise hover event. - * - * @param className - */ -// public static void moveToHTMLElementByClassName(String className) { -// Actions actions = new Actions(GeneralUIUtils.getDriver()); -// final WebElement createButtonsArea = GeneralUIUtils -// .retryMethodOnException(() -> GeneralUIUtils.getDriver().findElement(By.className(className))); -// actions.moveToElement(createButtonsArea).perform(); -// } - - /** - * Move to HTML element by element id. When moving to the HTML element, it - * will raise hover event. - * - * @param className - */ -// static void moveToHTMLElementByDataTestId(String dataTestId) { -// // WebElement hoverArea = -// // GeneralUIUtils.getDriver().findElement(By.xpath("//*[@data-tests-id='" -// // + dataTestId + "']")); -// WebElement hoverArea = GeneralUIUtils.waitForElementVisibility(dataTestId); -// // WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), -// // 30); -// // wait.until(ExpectedConditions.visibilityOf(hoverArea)); -// -// Actions actions = new Actions(GeneralUIUtils.getDriver()); -// actions.moveToElement(hoverArea).perform(); -// } - - // public static ResourceReqDetails createResourceInUI(User user){ - // try{ - // ResourceReqDetails defineResourceDetails = - // defineResourceDetails(ResourceTypeEnum.VF); - // ResourceUIUtils.moveToHTMLElementByClassName("w-sdc-dashboard-card-new"); - // ResourceUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_VF.getValue()); - // GeneralUIUtils.waitForLoader(); - //// GeneralUIUtils.sleep(1000); - // fillResourceGeneralInformationPage(defineResourceDetails, user); - // GeneralPageElements.clickCreateButton(); - // return defineResourceDetails; - // } - // catch( Exception e){ - // throw new RuntimeException(e); - // } - // } - - /** * Import VFC * * @param user @@ -983,141 +339,6 @@ public final class ResourceUIUtils { ExtentTestActions.log(Status.INFO, "VF is updated."); } - - - // public static ResourceReqDetails importVfcInUI(User user, String - // filePath, String fileName, ResourceTypeEnum resourceType) { - // ResourceReqDetails defineResourceDetails = - // defineResourceDetails(resourceType); - // ResourceUIUtils.moveToHTMLElementByDataTestId(Dashboard.IMPORT_AREA.getValue()); - // - // // Insert file to the browse dialog - // final WebElement browseWebElement = - // GeneralUIUtils.getWebElementByDataTestId(DataTestIdEnum.Dashboard.IMPORT_VFC_FILE.getValue()); - // browseWebElement.sendKeys(filePath + fileName); - // - // // Fill the general page fields. - // GeneralUIUtils.waitForLoader(); - // fillResourceGeneralInformationPage(defineResourceDetails, user); - // GeneralPageElements.clickCreateButton(); - // return defineResourceDetails; - // } - - /** - * Import VF - * - * @param user - * @param filePath - * @param fileName - * @return - * @throws Exception - */ - // public static ResourceReqDetails importVfInUI(User user, String filePath, - // String fileName) throws Exception { - // ResourceReqDetails defineResourceDetails = - // defineResourceDetails(ResourceTypeEnum.VF); - // ResourceUIUtils.moveToHTMLElementByDataTestId(Dashboard.IMPORT_AREA.getValue()); - // - // // Insert file to the browse dialog - // final WebElement browseWebElement = - // GeneralUIUtils.getWebElementByDataTestId(DataTestIdEnum.Dashboard.IMPORT_VF_FILE.getValue()); - // browseWebElement.sendKeys(filePath + fileName); - // - // // Fill the general page fields. - // GeneralUIUtils.waitForLoader(); - // fillResourceGeneralInformationPage(defineResourceDetails, user); - // GeneralPageElements.clickCreateButton(); - // return defineResourceDetails; - // } - - // public static ResourceReqDetails defineResourceDetails(ResourceTypeEnum - // resourceType) { - // ResourceReqDetails resource = new ResourceReqDetails(); - // resource = ElementFactory.getDefaultResource(NormativeTypesEnum.ROOT, - // ResourceCategoryEnum.APPLICATION_L4_CALL_CONTROL); - // resource.setVersion(INITIAL_VERSION); - // resource.setIcon(ICON_RESOURCE_NAME); - // resource.setResourceType(resourceType.toString()); - // resource.setName(getRandomComponentName(RESOURCE_NAME_PREFIX)); - // - // SetupCDTest.setCreatedComponents(Arrays.asList(resource)); - // - // return resource; - // } - - protected static String getRandomComponentName(String prefix) { - return prefix + new Random().nextInt(10000); - } - - public static ImmutablePair<String, String> getFirstRIPos(ResourceReqDetails createResourceInUI, User user) { - String responseAfterDrag = RestCDUtils.getResource(createResourceInUI, user).getResponse(); - JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - String xPosPostDrag = (String) ((JSONObject) ((JSONArray) jsonResource.get("componentInstances")).get(0)) - .get("posX"); - String yPosPostDrag = (String) ((JSONObject) ((JSONArray) jsonResource.get("componentInstances")).get(0)) - .get("posY"); - return new ImmutablePair<String, String>(xPosPostDrag, yPosPostDrag); - - } - - public static WebElement getErrorMessageText(WebDriver driver, String text) throws Exception { - - return GeneralUIUtils.getWebElementByClassName(text); - - } - - public static void fillGeneralInfoValuesAndIcon(ResourceReqDetails resource, User user) throws Exception { - fillResourceGeneralInformationPage(resource, user, true); - - GeneralPageElements.clickCreateButton(); - - selectRandomResourceIcon(); - } - - // coded by teddy. - public static void getVFCGeneralInfoAndValidate(ResourceReqDetails resource, User user) - throws InterruptedException { - Thread.sleep(2000); - WebDriver driver = GeneralUIUtils.getDriver(); - String version = GeneralUIUtils.getSelectList(null, "versionHeader").getFirstSelectedOption().getText(); - String name = GeneralUIUtils.getWebElementByTestID( "name").getAttribute("value"); - String description = GeneralUIUtils.getWebElementByTestID( "description").getAttribute("value"); - String category = GeneralUIUtils.getSelectList(null, "selectGeneralCategory").getFirstSelectedOption() - .getText(); - String vendorName = GeneralUIUtils.getWebElementByTestID( "vendorName").getAttribute("value"); - String vendorRelease = GeneralUIUtils.getWebElementByTestID( "vendorRelease").getAttribute("value"); - List<WebElement> tags = GeneralUIUtils.getWebElementsListByTestID("i-sdc-tag-text"); - String type = GeneralUIUtils.getWebElementsListByTestID("type").get(1).getText(); - int index = type.lastIndexOf(":"); - System.out.println(type.substring(0, index)); - String AttContact = GeneralUIUtils.getWebElementByTestID( "attContact").getAttribute("value"); - System.out.println(resource.getVersion()); - assertTrue(resource.getVersion().equals(version.substring(1))); - assertTrue(resource.getName().equals(name)); - assertTrue(resource.getDescription().equals(description)); - System.out.println(resource.getVendorName()); - System.out.println(resource.getVendorRelease()); - assertTrue(resource.getCategories().get(0).getSubcategories().get(0).getName().equals(category)); - assertTrue(resource.getVendorName().equals(vendorName)); - assertTrue(resource.getVendorRelease().equals(vendorRelease)); - assertTrue(resource.getCreatorUserId().equals(AttContact)); - assertEquals(type.substring(0, index), resource.getResourceType()); - - for (int i = 0; i < tags.size(); i++) { - assertEquals(resource.getTags().get(i), tags.get(i).getText()); - } - } - - public static RestResponse createResourceNG(ResourceReqDetails resource, User user) throws Exception, AWTException { - - GeneralUIUtils.hoverOnAreaByTestId("w-sdc-dashboard-card-new"); - ResourceUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_VF.getValue()); - fillResourceGeneralInformationPage(resource, user, true); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue()); - return null; - - } - public static void showButtons(){ String parentElementClassAttribute = "sdc-dashboard-import-element-container"; WebElement fileInputElementWithVisible = GeneralUIUtils.getDriver().findElement(By.className(parentElementClassAttribute)); @@ -1150,7 +371,25 @@ public final class ResourceUIUtils { } public static void createPNF(ResourceReqDetails resource, User user) throws Exception { - ExtentTestActions.log(Status.INFO, "Going to create a new PNF."); + ExtentTestActions.log(Status.INFO, "Going to create a new PNF"); createResource(resource, user, DataTestIdEnum.Dashboard.BUTTON_ADD_PNF); } + + public static void createCR(ResourceReqDetails resource, User user) throws Exception { + ExtentTestActions.log(Status.INFO, "Going to create a new CR"); + createResource(resource, user, DataTestIdEnum.Dashboard.BUTTON_ADD_CR); + } + + public static ImmutablePair<String, String> getFirstRIPos(ResourceReqDetails createResourceInUI, User user) { + String responseAfterDrag = RestCDUtils.getResource(createResourceInUI, user).getResponse(); + JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); + String xPosPostDrag = (String) ((JSONObject) ((JSONArray) jsonResource.get("componentInstances")).get(0)) + .get("posX"); + String yPosPostDrag = (String) ((JSONObject) ((JSONArray) jsonResource.get("componentInstances")).get(0)) + .get("posY"); + return new ImmutablePair<String, String>(xPosPostDrag, yPosPostDrag); + + } + + } |