@BeforeMethod public void initial() { userName = "******" + randUser; email = "test" + randUser + "@symantec.com"; System.out.println("Random user is " + userName); swagger.updateUserResourcePrivilegeAPI(loginUserId, USER_MANAGEMENT, MODIFY); // Create user userId = swagger.createUserAPI(userName, userName, userName, email); // Get random BH node and resource each time String resources[] = swagger.getResourcesAPI(); int index = rand(resources.length - 1); resource = resources[index + 1]; bhNode = "GLOBAL"; privilege = "Modify"; System.out.println("Resource is " + resource); driver = initialization(); }
@Test(groups = {"user_mgt", "permission"}) public void deletePermissionTest() throws InterruptedException { LandingPage landing_page = PageFactory.initElements(driver, LandingPage.class); WelcomePage welcomePage = PageFactory.initElements(driver, WelcomePage.class); GlobalNavigatePage global_nav_page = PageFactory.initElements(driver, GlobalNavigatePage.class); UserMgtBasePage user_base_page = PageFactory.initElements(driver, UserMgtBasePage.class); UserMgtUserPage user_page = PageFactory.initElements(driver, UserMgtUserPage.class); UserMgtRolePage role_page = PageFactory.initElements(driver, UserMgtRolePage.class); landing_page.signIn(loginUserName, loginUserName); welcomePage.selectNortonStore(); global_nav_page.navigateToUserManagement(); user_base_page.goToUsersTab(); sleep(3000); user_page.search_box.sendKeys(userName); sleep(2000); user_page.user_list_checkBox.click(); user_page.permission_narrow.click(); sleep(5000); // Assign resource permission user_page.new_permission_tab.click(); sleep(3000); role_page.selectDropDown(role_page.bhNode_dropdown, role_page.bhNode_options, bhNode); sleep(3000); role_page.selectDropDown( role_page.role_resource_dropdown, role_page.role_resource_options, resource); sleep(3000); role_page.setPrivilege(privilege); sleep(1000); user_page.confirm_btn.click(); sleep(2000); // Assign duplicated resource permission user_page.new_permission_tab.click(); sleep(3000); role_page.selectDropDown(role_page.bhNode_dropdown, role_page.bhNode_options, bhNode); sleep(3000); role_page.selectDropDown( role_page.role_resource_dropdown, role_page.role_resource_options, resource); sleep(3000); role_page.setPrivilege(privilege); sleep(1000); user_page.confirm_btn.click(); sleep(2000); // Error msg should show up Assert.assertEquals( true, user_page.error_msg.getText().contains("There was an issue creating the permission"), "Duplicated resource-permission is created successfully"); String currentUrl = driver.getCurrentUrl(); Assert.assertEquals( false, user_page.delete_permission_tab.isEnabled(), "Delete permission tab is enabled before selecting resource-permission"); user_page.search_box.sendKeys(resource); sleep(1000); user_page.permission_list_checkbox.click(); sleep(3000); Assert.assertEquals( true, user_page.delete_permission_tab.isEnabled(), "Delete permission tab is NOT enabled after selecting resource-permission"); user_page.delete_permission_tab.click(); sleep(5000); // Verify permission deletion dialog Assert.assertEquals( true, user_page.delete_permission_dialog_title.isDisplayed(), "Delete permission dialog title is not present"); Assert.assertEquals( true, user_page.confirm_btn.isEnabled(), "Delete permission confirm OK button is not enabled"); Assert.assertEquals( true, user_page.cancel_btn.isEnabled(), "Delete permission Cancel button is not enabled"); user_page.cancel_btn.click(); // Verify delete permission cancellation Assert.assertEquals( currentUrl, driver.getCurrentUrl(), "Cancel permission cancellation is not successfully"); // Delete permission user_page.delete_permission_tab.click(); user_page.confirm_btn.click(); sleep(2000); Assert.assertEquals( true, user_page.error_msg.getText().contains("Successfully deleted the permission"), "Delete permission NOT successfully"); // Clear up swagger.deleteUserAPI(userId); }