def clickPolicyEntryActionsDropdown(self, retryCount=3, timeout=10): self.checkElementonPage( locatorName=self.getPolicyEntryActionsDropdown(), locatorMessage='Policy Entry Drop Down Present', retryCount=retryCount, timeout=timeout) SeleniumDP.click(self.driver, self.getPolicyEntryActionsDropdown())
def clickDestinationClusterDropdownItem1(self): self.checkElementonPage( locatorName=self.getDestinationClusterDropdownItem1( returnLocatorName=True), locatorMessage='Destination Cluster Dropdown Item #1 Visible') SeleniumDP.click(self.driver, self.getDestinationClusterDropdownItem1())
def clickPolicyEntryActionsViewLog(self, retryCount=3, timeout=10): self.checkElementonPage( locatorName=self.getPolicyEntryActionsViewLog(), locatorMessage='Delete Option Visible', retryCount=retryCount, timeout=timeout) SeleniumDP.click(self.driver, self.getPolicyEntryActionsViewLog())
def clickRefreshCluster(self, rowNum, retryNum=3): try: SeleniumDP.click(self.driver, self.getClusterRefreshClickableElement()) return True except Exception as e: # We might reach this point only if StaleElementReferenceException # is seen where-in we might need to invoke the whole process again logger.error( "Caught an exception: %s, Let's retry to try our luck !!!" % e) if retryNum > 0: logger.info("Retry Attempt: %s" % retryNum) logger.info( "Invoking clickClusterButtonAndValidateHoverVisibility" "for Row: %s since refresh caused cache to loose state" % rowNum) if self.clickClusterButtonAndValidateHoverVisibility( rowNum=rowNum): logger.info( "Hover visible in clickRefreshCluster, Proceeding to click now" ) return self.clickRefreshCluster(rowNum, retryNum - 1) else: logger.error( "No point proceeding further ... Failing the test") return False else: logger.info("Retry Attempts failed") return False
def clickToGoToPolicyLandingPage(self, policyType): IS_HUMBOLDT = Machine.isWindows() global serviceName, service_name_type_dict, service_name_type_dict_for_Humboldt service_name_type_dict_for_Humboldt = { 'hadoop': 'hadoopdev', 'hive': 'hivedev', 'hbase': 'hbasedev', 'knox': 'knoxdev', 'storm': 'stormdev' } service_name_type_dict = { 'hadoop': xa_testenv.getEnv("XA_HDFS_REPO_NAME", "hadoopdev"), 'hive': xa_testenv.getEnv("XA_HIVE_REPO_NAME", "hivedev"), 'hbase': xa_testenv.getEnv("XA_HBASE_REPO_NAME", "hbasedev"), 'knox': xa_testenv.getEnv("XA_KNOX_REPO_NAME", "knoxdev"), 'storm': xa_testenv.getEnv("XA_STORM_REPO_NAME", "stormdev") } if IS_HUMBOLDT: logger.info("Its a Humboldt cluster !!") serviceName = service_name_type_dict_for_Humboldt[policyType] else: logger.info("Its NOT a Humboldt cluster !!") serviceName = service_name_type_dict[policyType] logger.info("serviceName: " + serviceName) SeleniumDP.click(self.driver, self.getServiceLink(policyType, serviceName))
def selectClusterToEdit(self, clusterName): self.isInfraLandingPage(retryCount=2) clusterInfoTableExists = self.checkElementonPage( locatorName=self.getClusterInfoTable(returnLocatorName=True), locatorMessage='Clusters info table', retryCount=5) if clusterInfoTableExists: tries = 5 while tries > 0: try: clusterInfoTableBody = self.findElement( *self.locator_dictionary[self.getClusterInfoTableBody( returnLocatorName=True)]) for row in clusterInfoTableBody.find_elements( By.TAG_NAME, 'tr'): columns = row.find_elements(By.TAG_NAME, 'td') if clusterName.lower() == columns[1].text.lower(): actionsButton = columns[7].find_element( By.TAG_NAME, 'button') SeleniumDP.click(self.driver, actionsButton) dropDownMenuElement = columns[7].find_element( By.TAG_NAME, 'ul') dropDownOptions = dropDownMenuElement.find_elements( By.TAG_NAME, 'li') for option in dropDownOptions: entries = option.find_elements( By.TAG_NAME, 'a') for entry in entries: if entry.text.lower() == 'edit': SeleniumDP.click(self.driver, entry) return except: tries = tries - 1
def validatePolicyCreationFailure(self, retryCount=3, timeout=5): assert self.checkElementonPage( locatorName=self.getPolicyCreationFailMessage( returnLocatorName=True), locatorMessage='Policy Creation Fail Message Visible', retryCount=retryCount, timeout=timeout) assert self.checkElementonPage( locatorName=self.getPolicyCreationErrorDetails( returnLocatorName=True), locatorMessage="Policy Creation Error Details Button Visible", retryCount=retryCount, timeout=timeout) SeleniumDP.click(self.driver, self.getPolicyCreationErrorDetails()) assert self.checkElementonPage( locatorName=self.getPolicyCreationFailDialog( returnLocatorName=True), locatorMessage="Policy Creation Fail Dialog Visible", retryCount=retryCount, timeout=timeout) assert self.checkElementonPage( locatorName=self.getdlmModalDialogOKButton(returnLocatorName=True), locatorMessage="OK Button Visible", retryCount=retryCount, timeout=timeout) SeleniumDP.click(self.driver, self.getdlmModalDialogOKButton())
def clickClusterDetailsDropDownClusterOne(self): self.checkElementonPage( locatorName=self.getClusterDetailsDropDownClusterOne( returnLocatorName=True), locatorMessage='Clusters Details DropDown', retryCount=2) SeleniumDP.click(self.driver, self.getClusterDetailsDropDownClusterOne())
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 signOutUnauthorizedUser(self): unauthorizedUserNotificationTitleExists = self.checkElementonPage( locatorName=self.getUnauthorizedNotificationTitleElement( returnLocatorName=True), locatorMessage='User Status label ', retryCount=15) if unauthorizedUserNotificationTitleExists: SeleniumDP.click(self.driver, self.getUnauthorizedNotificationSignOutElement())
def getLoggedInUserName(self): SeleniumDP.click(self.driver, self.getLogoutMenu()) self.checkElementonPage( locatorName=self.getLoggedInUser(returnLocatorName=True), locatorMessage='Logout Button', retryCount=4, timeout=0.5) loggedInUser = self.getLoggedInUser().text SeleniumDP.click(self.driver, self.getLoggedInUser()) return loggedInUser
def checkIfSearchFilterElementIsClickable(self, searchFilterElement): if searchFilterElement.is_enabled(): logger.info( "searchFilterElement is available and clickable, Proceeding to click ..." ) SeleniumDP.click(self.driver, searchFilterElement) self.take_screenshot("checkIfSearchFilterElementIsClickable") return True else: logger.error("SearchFilterElement: %s is not enabled yet" % searchFilterElement.text) return False
def clickClusterDetailsDropDownClusterOneHdfsBrowserTmpDirElement(self): # First time loading of HDFS data is slow self.checkElementonPage( locatorName=self. getClusterDetailsDropDownClusterOneHdfsBrowserTmpDirElement( returnLocatorName=True), locatorMessage='HDFS Browser tmp Dir Displayed', timeout=10, retryCount=5) SeleniumDP.click( self.driver, self.getClusterDetailsDropDownClusterOneHdfsBrowserTmpDirElement())
def clickClusterTableSortableHeader(self, clickableElement): """ Clicks the Cluster Table Header element which comes in as the input argument """ try: SeleniumDP.click(self.driver, clickableElement) logger.info("Clicked the element") return True except Exception as e: logger.info("Caught Exception: %s" % e) return False
def clickClusterRowButton(self, buttonRowNum): xpathForRowButton = "//table/tbody/tr[%s]/td[8]/button" % buttonRowNum InfraLandingPage.locator_dictionary["clusterRowButton"] = ( By.XPATH, xpathForRowButton) if self.getClusterRowButton().is_enabled(): logger.info( "Button is available and clickable, Proceeding to click ...") SeleniumDP.click(self.driver, self.getClusterRowButton()) return True else: logger.error( "ClusterRowButton not clickable, might need a retry !!!") return False
def removeAllSearchFiltersApplied(self): """ Removes all the search filters applied on the cluster table """ searchFiltersApplied = self.getAllSearchFiltersApplied() if searchFiltersApplied: for searchFilter in searchFiltersApplied: SeleniumDP.click(self.driver, searchFilter) logger.info("%s filter/s removed" % len(searchFiltersApplied)) return True else: logger.info("No filters are applied") return False
def switchUserStatusToInactive(self): userStatusLabelExists = self.checkElementonPage( locatorName=self.getStatusSwitchLabelElement( returnLocatorName=True), locatorMessage='User Status label ', retryCount=15) if userStatusLabelExists: currentStatus = self.findElement( *self.locator_dictionary[self.getStatusSwitchLabelElement( returnLocatorName=True)]).text if currentStatus.lower() == 'active': SeleniumDP.click(self.driver, self.getStatusSwitchToggleElement()) else: logger.info("--- Current user status is Inactive")
def viewClusterDetails(self, clusterName): self.isInfraLandingPage(retryCount=2) clusterInfoTableExists = self.checkElementonPage( locatorName=self.getClusterInfoTable(returnLocatorName=True), locatorMessage='Clusters info table', retryCount=5) if clusterInfoTableExists: clusterInfoTableBody = self.findElement( *self.locator_dictionary[self.getClusterInfoTableBody( returnLocatorName=True)]) for row in clusterInfoTableBody.find_elements(By.TAG_NAME, 'tr'): columns = row.find_elements(By.TAG_NAME, 'td') if clusterName.lower() == columns[1].text.lower(): SeleniumDP.click(self.driver, columns[1]) break
def editUser(self, username): self.isUsersPage() userInfoTableExists = self.checkElementonPage( locatorName=self.getUsersInfoTableBody(returnLocatorName=True), locatorMessage='Users info table', retryCount=15) if userInfoTableExists: userInfoTable = self.findElement( *self.locator_dictionary[self.getUsersInfoTableBody( returnLocatorName=True)]) for row in userInfoTable.find_elements(By.TAG_NAME, 'tr'): columns = row.find_elements(By.TAG_NAME, 'td') if username.lower() == columns[0].text.lower(): SeleniumDP.click(self.driver, columns[0]) self.take_screenshot("editUser") break
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 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 doLogout(self): # Element Ids are different for DLM and DP if 'dlm' in self.getCurrentURL().lower(): SeleniumDP.click(self.driver, self.getUserDropdown()) self.checkElementonPage( locatorName=self.getLogoutButtonDLM(returnLocatorName=True), locatorMessage='Logout Button DLM', retryCount=4, timeout=0.5) SeleniumDP.click(self.driver, self.getLogoutButtonDLM()) else: SeleniumDP.click(self.driver, self.getLogoutMenu()) self.checkElementonPage( locatorName=self.getLogoutButton(returnLocatorName=True), locatorMessage='Logout Button', retryCount=4, timeout=0.5) #SeleniumDP.clickUsingClickable(self.getLogoutButton()) SeleniumDP.click(self.driver, self.getLogoutButton())
def clickOnOkBtnInPopupForMaskValueNotEntered(self, driver): SeleniumDP.click(driver, self.getOkBtnInPopupForMaskValueNotEntered())
def clickOnCustomMaskOptionRadioBtnInPopup(self, driver): SeleniumDP.click(driver, self.getRadioBtnForCustomMaskingOption())
def clickOnTickBtnToAddMaskOptionsInPopup(self, driver): SeleniumDP.click(driver, self.getTickBtnToAddMaskOptionsInPopup())
def clickOnAddMaskingOptionsBtn(self, driver): SeleniumDP.click(driver, self.getAddMaskingOptionBtnInFirstPermRow())
def clickGetStartedButton(self): SeleniumDP.click(self.driver, self.getGetStartedButton())
def clickFlowID(self, user, flowName): SeleniumDP.click(self.driver, self.getFlowID(user, flowName))
def clickflowRunMetrics(self, user, flowName, runID): SeleniumDP.click(self.driver, self.getFlowRunMetrics(user, flowName, runID))
def clickXOnPair(self): self.checkElementonPage( locatorName=self.getXOnPair(returnLocatorName=True), locatorMessage='Unpair Button Visible') SeleniumDP.click(self.driver, self.getXOnPair())