def enableDSS(self, smartsenseId="A-12341234-C-12341234"): # Click SideNav self.clickSideNavServices() # Verify DSS Service Box is visible self.checkElementonPage( locatorName=self.getDssServiceBox(returnLocatorName=True), locatorMessage='DSS Service Box', retryCount=4) # Click DSS service box to Enable the DSS Button, then click that Button self.clickDssServiceBox() self.clickEnableDssButton() # Verify the next screen for Smartsense Id is visible self.checkElementonPage( locatorName=self.getSmartsenseId(returnLocatorName=True), locatorMessage='Smartsense ID Input Field', retryCount=4) SeleniumDP.sendKeys(self.getSmartsenseId(), smartsenseId) # Click Next Button self.clickNextButton() # Verify the message that service is enabled is displayed self.checkElementonPage( locatorName=self.getSuccessHeading(returnLocatorName=True), locatorMessage= 'Success Heading for DSS Service Enablement Displayed', retryCount=4)
def viewPolicyLog(self, policyName): SeleniumDP.sendKeys(self.getFilterInput(), policyName + '\n') self.clickPolicyEntryActionsDropdown() self.checkElementonPage( locatorName=self.getPolicyEntryActionsViewLog(), locatorMessage='Suspend Action Button Visible', retryCount=3, timeout=5) SeleniumDP.click(self.driver, self.getPolicyEntryActionsViewLog())
def setCustomMaskingOption(self, driver, customMaskValue): self.clickOnAddMaskingOptionsBtn(driver) self.waitForElement( self, self.getMaskingOptionHeadingInMaskingPopup(returnLocatorName=True)) self.clickOnCustomMaskOptionRadioBtnInPopup(driver) self.clickOnTickBtnToAddMaskOptionsInPopup(driver) self.waitForElement( self, self.getInputBoxForEnteringCustomMaskValue(returnLocatorName=True)) SeleniumDP.sendKeys(self.getInputBoxForEnteringCustomMaskValue(), customMaskValue)
def validatePolicyStatusOnUI(self, policyName, action): if action == 'Delete': SeleniumDP.sendKeys(self.getFilterInput(), policyName) assert self.checkElementonPage( locatorName=self.getElement('policyDoesntExistInFilter', returnLocatorName=True), locatorMessage='No Data to Show Message', retryCount=3, timeout=5) elif action == 'Suspend': assert self.getPolicyStatusOnUI(policyName).text == 'SUSPENDED' elif action == 'Activate': assert self.getPolicyStatusOnUI(policyName).text == 'ACTIVE'
def createHiveReplicationPolicy(self, policyName, dbname, policyDescription='', policyFrequency='2', policyFrequencyUnit='minute'): self.clickAddPolicyButton() self.checkElementonPage( locatorName=self.getPolicyName(returnLocatorName=True), locatorMessage='Create Replication Policies Page', retryCount=1) SeleniumDP.sendKeys(self.getPolicyName(), policyName) SeleniumDP.sendKeys(self.getPolicyDescription(), policyDescription) self.clickPolicyTypeHive() self.clickSourceClusterDropdown() self.clickSourceClusterDropdownItem1() self.clickDestinationClusterDropdown() self.clickDestinationClusterDropdownItem1() SeleniumDP.sendKeys(self.getDBSearch(), dbname) self.clickDBEntry() self.clickPolicyStartFromNow() SeleniumDP.sendKeys(self.getPolicyFrequency(), policyFrequency) self.clickPolicyUnitDropdown() if policyFrequencyUnit == 'minute': self.clickPolicyUnitDropdownMinute() elif policyFrequencyUnit == 'hour': self.clickPolicyUnitDropdownHour() elif policyFrequencyUnit == 'day': self.clickPolicyUnitDropdownDay() else: self.clickPolicyUnitDropdownWeek() self.clickPolicySubmitButton() self.clickPolicySubmitButton()
def policyAction(self, policyName, action): self.checkElementonPage( locatorName=self.getFilterInput(returnLocatorName=True), locatorMessage='Filter field visible', retryCount=3) SeleniumDP.sendKeys(self.getFilterInput(), policyName + '\n') self.clickPolicyEntryActionsDropdown() if action == 'Delete': self.clickPolicyEntryActionsDelete() elif action == 'Suspend': self.clickPolicyEntryActionsSuspend() elif action == 'Activate': self.clickPolicyEntryActionsActivate() self.clickPolicyDialogYesButton()
def editClusterDatacenter(self, newClusterDatacenter): editClusterLocationExists = self.checkElementonPage( locatorName=self.getEditClusterLocationElement( returnLocatorName=True), locatorMessage='Edit Cluster Location', retryCount=2) editClusterDatacenterExists = self.checkElementonPage( locatorName=self.getEditClusterDatacenterElement( returnLocatorName=True), locatorMessage='Edit Cluster Datacenter', retryCount=2) if editClusterLocationExists and editClusterDatacenterExists: SeleniumDP.sendKeys(self.getEditClusterDatacenterElement(), newClusterDatacenter) return
def enableDLM(self, smartsenseId="A-12341234-C-12341234", verifyInvalidSmartSenseId=False): # Click SideNav self.clickSideNavServices() # Verify Dlm Service Box is visible self.checkElementonPage( locatorName=self.getDlmServiceBox(returnLocatorName=True), locatorMessage='DLM Service Box', retryCount=4, timeout=0.5) # Click DlmServiceBox to Enable the DLM Button, then click that Button self.clickDlmServiceBox() self.clickEnableDlmButton() # Verify the next screen for Smartsense Id is visible self.checkElementonPage( locatorName=self.getSmartsenseId(returnLocatorName=True), locatorMessage='Smartsense ID Input Field', retryCount=4, timeout=0.5) SeleniumDP.sendKeys(self.getSmartsenseId(), smartsenseId) # Verify Invalid SmartSenseId if verifyInvalidSmartSenseId: self.clickVerifyButton() assert self.checkElementonPage( locatorName=self.getSmartsenseIdIncorrectFormat( returnLocatorName=True), locatorMessage= 'Smartsense ID Incorrect Format Message Displayed', retryCount=1) self.clickCancelButton() return # Click Next Button self.clickNextButton() # Verify the message that service is enabled is displayed self.checkElementonPage( locatorName=self.getSuccessHeading(returnLocatorName=True), locatorMessage= 'Success Heading for DLM Service Enablement Displayed', retryCount=4, timeout=2)
def enterGroup(self, group, attempts=2): SeleniumDP.sendKeys(self.getGroupsInputField(), group) if self.checkElementonPage( locatorName=self.getGroupsDropdownSearchingRow( returnLocatorName=True), locatorMessage='Groups DropDown Searching Row Visible', retryCount=1, timeout=1): self.waitForElementInvisibility( self.getGroupsDropdownSearchingRow(returnLocatorName=True)) if self.checkElementonPage( locatorName=self.getGroupsDropdownRow(returnLocatorName=True), locatorMessage='Groups DropDown Visible', retryCount=1, timeout=1): SeleniumDP.click(self.driver, self.getGroupsDropdownRow()) else: self.enterGroup(group, attempts=attempts - 1)
def enterAmbariURLAndValidate( self, ambariURL, invalidURL=False, incorrectAmbariHost=False, clusterAlreadyExists=False, mandatoryFieldsTest=False ): SeleniumDP.sendKeys(self.getAmbariURLInputField(), ambariURL) self.clickGoButton() if invalidURL: # Waiting for 0 seconds for Invalid Ambari URL message to load assert self.checkElementonPage( locatorName=self.getInvalidAmbariURL(returnLocatorName=True), locatorMessage='Invalid Ambari URL Message Displayed', retryCount=0 ) elif clusterAlreadyExists: # Waiting for 0 seconds for Cluster Already Exists message to load assert self.checkElementonPage( locatorName=self.getClusterAlreadyExists(returnLocatorName=True), locatorMessage='Cluster Already Exists Message Displayed', retryCount=0 ) elif incorrectAmbariHost: # Waiting for max 30 seconds for Error Message to load assert self.checkElementonPage( locatorName=self.getErrorMessage(returnLocatorName=True), locatorMessage='Error Message - Dataplane could not retreive cluster information Displayed', retryCount=3, timeout=10 ) else: # Waiting for max 60 seconds for Cluster details to load assert self.checkElementonPage( locatorName=self.getClusterLocationField(returnLocatorName=True), locatorMessage='Add Cluster Details Parameters Displayed', retryCount=6, timeout=10 ) if mandatoryFieldsTest: SeleniumDP.sendKeys(self.getClusterLocationField(), "San Jose, California, United States of America") time.sleep(2) SeleniumDP.clickUsingClickable(self.getClusterLocationAutoComplete())
def validateInvalidPolicyPath(self): self.clickAddPolicyButton() self.checkElementonPage( locatorName=self.getPolicyName(returnLocatorName=True), locatorMessage='Create Replication Policies Page', retryCount=1) SeleniumDP.sendKeys(self.getPolicyName(), "Invalid") self.clickPolicyTypeHdfs() self.clickSourceClusterDropdown() self.clickSourceClusterDropdownItem1() self.clickDestinationClusterDropdown() self.clickDestinationClusterDropdownItem1() SeleniumDP.sendKeys(self.getFolderPathInput(), "/AAAAA###BBTTT") self.clickFolderPathInputForm() time.sleep(2) self.clickFolderPathInputForm() assert self.checkElementonPage( locatorName=self.getFolderPathInputErrorMessage( returnLocatorName=True), locatorMessage='Invalid Path Error Message Visible', retryCount=2)
def editClusterLocation(self, newClusterLocation): editClusterLocationExists = self.checkElementonPage( locatorName=self.getEditClusterLocationElement( returnLocatorName=True), locatorMessage='Edit Cluster Location', retryCount=2) if editClusterLocationExists: tries = 5 while tries > 0: try: SeleniumDP.sendKeys(self.getEditClusterLocationElement(), newClusterLocation) clusterLocationDropdownVisible = self.waitForElement( locatorName=self.getClusterLocationDropdownElement( returnLocatorName=True)) if clusterLocationDropdownVisible: clusterLocationDropdown = self.findElement( *self.locator_dictionary[ self.getClusterLocationDropdownElement( returnLocatorName=True)]) options = clusterLocationDropdown.find_elements( By.TAG_NAME, 'li') for option in options: if option: SeleniumDP.sendKeys( self.getEditClusterLocationElement(), newClusterLocation + Keys.ENTER) if self.checkElementonPage( locatorName=self. getEditClusterLocationErrorTextElement( returnLocatorName=True), locatorMessage='Cluster Location Error' ): raise ValueError( 'Cluster Location Error text found') return except: self.take_screenshot("editClusterLocation") tries = tries - 1
def addCluster(self, ambariURL, clusterLocation, dataCenter, tags, description, clickAddAndNewButton=False): self.enterAmbariURLAndValidate(ambariURL) SeleniumDP.sendKeys(self.getClusterLocationField(), clusterLocation) time.sleep(2) SeleniumDP.clickUsingClickable(self.getClusterLocationAutoComplete()) SeleniumDP.sendKeys(self.getDataCenterField(), dataCenter) SeleniumDP.sendKeys(self.getTagsField(), tags) SeleniumDP.sendKeys(self.getDescriptionField(), description) if clickAddAndNewButton: self.clickAddAndNewButton() if self.isClearButtonDisplayed(): self.waitForElement(self.getGoButton(returnLocatorName=True)) else: self.clickAddButton()
def selectUsername(self, username): tries = 5 while tries > 0: try: SeleniumDP.sendKeys(self.getUsernameField(), username) dropDownElementExists = self.checkElementonPage( locatorName=self.getUsernameDropDownElement( returnLocatorName=True), locatorMessage='Drop Down element', retryCount=15) if dropDownElementExists: dropDownOptions = self.findElement( *self.locator_dictionary[ self.getUsernameDropDownElement( returnLocatorName=True)]) for option in dropDownOptions.find_elements( By.TAG_NAME, 'div'): if username == option.text.lower(): SeleniumDP.click(self.driver, option) self.take_screenshot("selectUsername") userTagExists = self.checkElementonPage( locatorName=self.getUsernameTaggingElement( returnLocatorName=True), locatorMessage='User Tags', retryCount=15) if userTagExists: userTags = self.findElement( *self.locator_dictionary[ self.getUsernameTaggingElement( returnLocatorName=True)]) for tag in userTags.find_elements( By.CLASS_NAME, 'tagSticker'): if username == tag.text.strip().lower(): self.take_screenshot("selectUsername") return except: tries = tries - 1
def submitTextIntoSearchBarAndValidateHoverContent(self, searchIndex): """ Submits the text into the search bar and validates if the content of the hover is appropriate """ searchField = self.getSearchBar() searchField.clear() SeleniumDP.sendKeys(searchField, searchIndex) if self.checkIfSearchFilterHoverIsVisible(): logger.info( "Search Filter Hover visible for the search index: %s" % searchIndex) filteredContent = self.getSearchFilterHoverContent() logger.info("Filtered content is: %s" % filteredContent) for line in filteredContent: if searchIndex.lower().rstrip() not in line.lower(): logger.info("Search index: %s not found in: %s" % (searchIndex, line)) return False return True else: logger.error( "Search Hover is not visible even after retry attempts") return False
def enterValuesInTagPolicyPg(self, driver, policyName, tagName, accessType, isAccessTypeToBeSet=False, grpName=None, userName=None, policyCondition=None): SeleniumDP.sendKeys(self.commonPolicyPg.getPolicyNameInput(), policyName) SeleniumDP.sendKeys(self.getTagInput(), tagName + u'\ue007' + u'\ue007') #SeleniumDP.sendKeys(self.getTagInput(), tagName+Keys.RETURN+Keys.RETURN) #self.waitForElement(self, self.getTagRsrcDropdownWithEnteredOption(returnLocatorName=True)) #self.waitForElement(self, self.getTagRsrcDropdownWithEnteredOption(tagName,returnLocatorName=True)) #self.clickOnTagRsrcDropdownWithEnteredOption(driver) self.waitForElement( self, self.getTagNameSetInInputBox(returnLocatorName=True)) self.commonPolicyPg.enterUserGroupPermissions(driver, accessType, isAccessTypeToBeSet, grpName, userName) if policyCondition is not None: self.clickOnAddPolicyConditionsBtnOnPage(driver) self.waitForElement( self, self.getExpiryDateInputBoxInPolicyCondPopup( returnLocatorName=True)) SeleniumDP.sendKeys(self.getBooleanExprTextAreaInPolCondPopup(), policyCondition) time.sleep(5) self.clickOnSubmitBtnInPolCondPopup(driver) self.waitForElement( self, self.getFilledPolCondExprOnPage(returnLocatorName=True)) self.clickOnAddCompPermsBtnOnPage(driver) time.sleep(3) SeleniumDP.sendKeys(self.getClickablePartInCompPermDropdownInPopup(), 'hive' + Keys.RETURN) self.waitForElement( self, self.getHiveCompPermSetInCompPermInputBoxInPopup( returnLocatorName=True)) self.clickOnGlobalHivePermCheckBoxInCompPermPopup(driver) time.sleep(3) self.clickOnSubmitBtnInCompPermPopup(driver)
def searchForAccessAuditBasedOnPolicyId(self, driver, policyId, accessEnforcer=None, accessType=None, clusterName=None, resourceName=None, resourceType=None, result=None, serviceName=None, serviceType=None, tags=None, user=None): if serviceType is not None: self.clickOnClickableAreaInSearchSection( driver) #--> Nothing happens SeleniumDP.sendKeys( self.getClickableAreaInSearchSection(), 'Service' ) #--> if no waitForElement, Service name gets selected #SeleniumDP.sendKeys(self.getClickableAreaInSearchSection(), Keys.RETURN) #--> clicks on access enforcer self.waitForElement( self, self.getServiceNameSearchCriteriaInDropdown( returnLocatorName=True)) self.clickOnServiceTypeSearchCriteriaInDropDown(driver) #SeleniumDP.sendKeys(self.getServiceTypeSearchCriteriaInDropdown(), Keys.RETURN) #--> throws InvalidElementStateException #SeleniumDP.sendKeys(self.getServiceTypeSearchCriteriaInDropdown(), Keys.NULL) #--> throws InvalidElementStateException #SeleniumDP.sendKeys(driver.switch_to.active_element, Keys.ARROW_DOWN) #--> clicks on access enforcer self.waitForElement( self, self.getServiceTypeLabelInSearchSection( returnLocatorName=True)) self.clickOnHiveServiceTypeInDropdown(driver) self.waitForElement( self, self.getHiveLabelInSearchSection(returnLocatorName=True)) self.clickOnClickableAreaInSearchSection(driver) SeleniumDP.sendKeys(self.getClickableAreaInSearchSection(), 'user') self.waitForElement( self, self.getUserSearchCriteriaInDropDown(returnLocatorName=True)) self.clickOnUserSearchCriteriaInDropDown(driver) self.waitForElement( self, self.getUserLabelInSearchSection(returnLocatorName=True)) SeleniumDP.sendKeys( self.getInputAreaForUserOptionInSearchSection(), user + Keys.RETURN) self.waitForElement( self, self.getUsernameLabelInSearchSection(user, returnLocatorName=True)) time.sleep(2)
def enterValuesInHivePolicyPg(self, driver, policyName, dbName, tableName, columnName, accessType, isAccessTypeToBeSet=False, grpName=None, userName=None): SeleniumDP.sendKeys(self.commonPolicyPg.getPolicyNameInput(), policyName) SeleniumDP.sendKeys(self.getHiveDbInput(), dbName) self.waitForElement( self, self.getHiveRsrcDropdownWithEnteredOption(returnLocatorName=True)) self.clickOnHiveRsrcDropdownWithEnteredOption(driver) self.waitForElement( self, self.getHiveDbNameSetInInputBox(returnLocatorName=True)) SeleniumDP.sendKeys(self.getHiveTableInput(), tableName) self.waitForElement( self, self.getHiveRsrcDropdownWithEnteredOption(returnLocatorName=True)) self.clickOnHiveRsrcDropdownWithEnteredOption(driver) self.waitForElement( self, self.getHiveTableNameSetInInputBox(returnLocatorName=True)) SeleniumDP.sendKeys(self.getHiveColumnInput(), columnName) self.waitForElement( self, self.getHiveRsrcDropdownWithEnteredOption(returnLocatorName=True)) self.clickOnHiveRsrcDropdownWithEnteredOption(driver) self.waitForElement( self, self.getHiveColumnNameSetInInputBox(returnLocatorName=True)) self.commonPolicyPg.enterUserGroupPermissions(driver, accessType, isAccessTypeToBeSet, grpName, userName)
def saveLDAPConfig(self, ldapURL, userSearchBase, userSearchAttribute, groupSearchBase, groupSearchAttribute, groupObjectClass, groupMemberAttrName, adminBindDn, adminPassword): SeleniumDP.sendKeys(self.getLdapURL(), ldapURL) SeleniumDP.sendKeys(self.getUserSearchBase(), userSearchBase) SeleniumDP.sendKeys(self.getUserSearchAttribute(), userSearchAttribute) SeleniumDP.sendKeys(self.getGroupSearchBase(), groupSearchBase) SeleniumDP.sendKeys(self.getGroupSearchAttribute(), groupSearchAttribute) SeleniumDP.sendKeys(self.getGroupObjectClass(), groupObjectClass) SeleniumDP.sendKeys(self.getGroupMemberAttrName(), groupMemberAttrName) SeleniumDP.sendKeys(self.getAdminBindDn(), adminBindDn) SeleniumDP.sendKeys(self.getAdminPassword(), adminPassword) self.clickSaveButton()
def doLogin(self, user_name, password): SeleniumDP.sendKeys(self.getUserNameTextBox(), user_name) SeleniumDP.sendKeys(self.getPasswordTextBox(), password) SeleniumDP.click(self.driver, self.getLoginButton())
def getPolicyStatusOnUI(self, policyName, returnLocatorName=False): SeleniumDP.sendKeys(self.getFilterInput(), policyName + '\n') return self.getElement('policyStatusFirstEntry', returnLocatorName=returnLocatorName)