def select_power_delivery_device(pddname): """ This function is to Select Power Delivery Device select_power_delivery_device Example: select_power_delivery_device(pddname) """ selenium2lib = ui_lib.get_s2l() navigate() if selenium2lib._is_element_present( FusionPowerDeliveryDevicePage.ID_PAGE_LABEL): """ check for Power Delivery Device exists """ if not (selenium2lib._is_element_present( FusionPowerDeliveryDevicePage.ID_ELEMENT_PDD_NAME_BASE % pddname.strip())): logger._warn("Power Delivery Device '%s' is not present" % pddname) selenium2lib.capture_page_screenshot() return False else: """ Select if Power Delivery Device exists """ ui_lib.wait_for_element_and_click( FusionPowerDeliveryDevicePage.ID_ELEMENT_PDD_NAME_BASE % pddname.strip()) ui_lib.wait_for_element( FusionPowerDeliveryDevicePage.ID_ELEMENT_PDD_NAME_BASE % pddname.strip() + "/ancestor::tr[contains(@class, hp-selected)]") # logger._log_to_console_and_log_file("Selected the Power Delivery Device %s successfully" % pddname) return True else: logger._log_to_console_and_log_file( "Fail in navigating to Power Delivery Device Page") selenium2lib.capture_page_screenshot() return False
def _validate_critical_object_hyper_link(component): """ validating dash board component's critical object hyper link """ if not ui_lib.wait_for_element(FusionDashboardPage.ID_PAGE_LABEL): navigate() ui_lib.wait_for_element( FusionDashboardPage.ID_CRITICAL_OBJECTS_COUNT % component, PerfConstants.DEFAULT_SYNC_TIME) critical_obj_count = ui_lib.get_text( FusionDashboardPage.ID_CRITICAL_OBJECTS_COUNT % component) logger._log_to_console_and_log_file( "number of objects with critical status :{0}".format( critical_obj_count)) ui_lib.wait_for_element(FusionDashboardPage.ID_CRITICAL_OBJECTS_COUNT % component) ui_lib.wait_for_element_and_click( FusionDashboardPage.ID_CRITICAL_OBJECTS_COUNT % component) if int(critical_obj_count) == 0: logger._log_to_console_and_log_file( "'{0}' Component does not have any critical status".format( component)) return True else: if not _validate_dashboard_component_hyper_link( component, critical_obj_count): return False
def filter_by_label_logical_switch_groups(*net_obj): s2l = ui_lib.get_s2l() if not ui_lib.wait_for_element(FusionLSGPage.ID_PAGE_LABEL): navigate() if isinstance(net_obj, test_data.DataObj): net_obj = [net_obj] elif isinstance(net_obj, tuple): net_obj = list(net_obj[0]) for net in net_obj: logger._log_to_console_and_log_file("Filtering LSG by label %s" % net.name) ui_lib.wait_for_element_and_click(FusionLSGPage.ID_FILTER_RESET) ui_lib.wait_for_element_and_click(FusionLSGPage.ID_FILTER_LABEL) ui_lib.wait_for_element_and_click( "//*[@id='cic-torswitchgroup-labels-filter']/ol/li[contains(.,'%s')]" % net.name) if ui_lib.wait_for_element(FusionLSGPage.ID_ELEMENT_LSG_NAME_BASE % net.lsgname): logger._log_to_console_and_log_file("LSG '%s' is present" % net.lsgname) else: return False ui_lib.wait_for_element_and_click(FusionLSGPage.ID_FILTER_RESET) return True
def delete_all_vcenters(): """ Delete all vCenters from appliance """ """Example: | `delete vCenter ` """ s2l = ui_lib.get_s2l() """ Navigate to vCenter Page """ if not ui_lib.wait_for_element(FusionvCenterPage.ID_PAGE_LABEL): navigate() count = 0 ui_lib.wait_for_element(FusionvCenterPage.ID_VCENTER_LIST) vCenter_list = [ ui_lib.get_webelement_attribute("text", el) for el in s2l._element_find(FusionvCenterPage.ID_VCENTER_LIST_NAMES, False, False) ] for vcenter in vCenter_list: logger._log_to_console_and_log_file("Deleting vCenter %s" % vcenter) if delete_vCenter(vcenter): count = count + 1 if len(vCenter_list) == count: logger._log_to_console_and_log_file( "SUCCESS: All vCenters are removed successfully") return True else: logger._log_to_console_and_log_file( "FAIL: Failed to remove few or all vCenters") return False
def check_availability_licenses(strlicense): """ check_availability_licenses Example: | check_availability_licenses("HP OneView") """ s2l = ui_lib.get_s2l() """ Call function to navigate to licenses """ if not ui_lib.wait_for_element(FusionSettingsPage.ID_PAGE_LABEL): _Navigate_To_Licenses() """ Check the availability of license in Licenses Page and get the License Number """ if ui_lib.wait_for_element(FusionSettingsPage.ID_LICENSE_AVAILABILITY % strlicense): ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_AVAILABLE_LICENSE % strlicense) intAvailableLicense = s2l._get_text(FusionSettingsPage.ID_AVAILABLE_LICENSE % strlicense) intAvlLicense = intAvailableLicense.split() if int(intAvlLicense[0].strip()) > 0: logger._log_to_console_and_log_file("License %s available with %s licenses" % (strlicense, str(intAvlLicense[0]))) return True else: logger._log_to_console_and_log_file("License %s available with %s licenses" % (strlicense, str(intAvlLicense[0]))) return False else: logger._log_to_console_and_log_file("License %s not available " % strlicense) return False
def del_directory_server(dServer, fail_on_err): """ del directory server from the appliance Example: settings.del_directory_users_and_groups(dServer, fail_on_err) """ # Navigate to the 'Settings' page navigate() selenium2lib = ui_lib.get_s2l() # Find the 'Security' Frame ui_lib.wait_for_element(FusionSettingsPage.ID_ELEMENT_SECURYTY_HEADER) # Does the server exist in 'Directories' field (list of existing directories). directories = selenium2lib.get_text(FusionSettingsPage.ID_ELEMENT_DIRECTORIES) if dServer.domainName in directories: logging._log_to_console_and_log_file("Removing directory server '%s'" % dServer.domainName) # Press the Edit Icon (next to Security). ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_SECURITY_EDIT) # wait until table is visible ui_lib.wait_for_element(FusionSettingsPage.ID_BTN_ADD_DIRECTORY_SETTINGS) # click X to delete the server ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_DIRECTORY_DEL % dServer.domainName) # confirm yes ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_REMOVE_SERVER_YES_BUTTON) # validate server is deleted if ui_lib.wait_for_element(FusionSettingsPage.ID_ELEMENT_SERVER_ALREADY_ADDED): logging._log_to_console_and_log_file("ERROR deleting the directory server '%s' was not deleted" % dServer.domainName) return False else: if fail_on_err: logging._log_to_console_and_log_file("Cannot delete - directory server did not exist in the list: '%s'" % dServer.domainName) ui_lib.fail_test("Cannot delete - directory server did not exist: '%s'" % dServer.domainName) return False
def navigate_settings_base(currentpage, menulink): logger._log_to_console_and_log_file('Navigating to "{0}"'.format(currentpage)) if not ui_lib.wait_for_element(currentpage): ui_lib.wait_for_element_and_click(FusionBasePage.ID_MAIN_MENU_CONTROL) ui_lib.wait_for_element(FusionBasePage.ID_MENU_LINK_USERS_AND_GROUPS, 10) ui_lib.wait_for_element_and_click(menulink) ui_lib.wait_for_element(currentpage)
def _validate_error_object_hyper_link(component): """ validating dash board component's error object hyper link """ if not ui_lib.wait_for_element(FusionDashboardPage.ID_PAGE_LABEL): navigate() ui_lib.wait_for_element( FusionDashboardPage.ID_OK_COUNT_SUMMARY % component, PerfConstants.DEFAULT_SYNC_TIME) ok_obj_count = int( ui_lib.get_text(FusionDashboardPage.ID_OK_COUNT_SUMMARY % component)) logger._log_to_console_and_log_file( "number of ok status are:{0}".format(ok_obj_count)) ui_lib.wait_for_element(FusionDashboardPage.ID_OK_COUNT_SUMMARY % component) ui_lib.wait_for_element_and_click(FusionDashboardPage.ID_OK_COUNT_SUMMARY % component) if int(ok_obj_count) == 0: logger._log_to_console_and_log_file( "'{0}' Component does not have any ok status".format(component)) return True else: if not _validate_dashboard_component_hyper_link( component, ok_obj_count): return False
def edit_services_access(isEnabled): """ Edit Support Access: function to enable or disable support access """ s2l = ui_lib.get_s2l() if not ui_lib.wait_for_element(FusionSettingsPage.ID_PAGE_LABEL): navigate() logger._log_to_console_and_log_file("Edit services access") ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_MENU_ACTION_MAIN_BTN) ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_MENU_ACTION_EDIT_SUPPORT_ACCESS) ui_lib.wait_for_element_visible(FusionSettingsPage.ID_LABEL_EDIT_SUPPORT_ACCESS) editoption = s2l.get_text(FusionSettingsPage.ID_TOGGLE_BTN_SERVICE_ACCESS) if editoption.lower() == isEnabled.lower(): ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_OK_SUPPORT_ACCESS) elif editoption == "Enabled" and isEnabled == "Disabled": ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_TOGGLE_OFF) ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_OK_SUPPORT_ACCESS) else: ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_TOGGLE_ON) ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_OK_SUPPORT_ACCESS) ui_lib.wait_for_element(FusionSettingsPage.ID_LABEL_STATUS) lablestatus = s2l.get_text(FusionSettingsPage.ID_LABEL_STATUS) if lablestatus.lower() == isEnabled.lower(): logger._log_to_console_and_log_file("Services access is successfully updated from '%s' to '%s'" % (editoption, isEnabled)) return True else: logger._warn("Failed to edit Services access ") return False
def navigate_base(currentpage, menulink, itemcount): s2l = ui_lib.get_s2l() logger._log_to_console_and_log_file( 'Navigating to "{0}"'.format(currentpage)) if not s2l._is_element_present(currentpage): ui_lib.wait_for_element(i3SBasePage.ID_MAIN_MENU_CONTROL, PerfConstants.DEFAULT_SYNC_TIME) ui_lib.wait_for_element_and_click(i3SBasePage.ID_MAIN_MENU_CONTROL, PerfConstants.DEFAULT_SYNC_TIME) ui_lib.wait_for_element(i3SBasePage.ID_MENU_LINK_DASHBOARD, PerfConstants.DEFAULT_SYNC_TIME) ui_lib.wait_for_element_and_click(menulink, PerfConstants.DEFAULT_SYNC_TIME) s2l.wait_until_page_contains_element(currentpage, PerfConstants.DEFAULT_SYNC_TIME) # wait for the page to get loaded s2l.wait_until_page_contains_element(itemcount, PerfConstants.DEFAULT_SYNC_TIME) # added wait to remove int Base 10 conversion error while running with Selenium speed 0.0 BuiltIn().sleep(1) for x in range(1, 5): try: el = int(s2l.get_text(itemcount)) except ValueError: BuiltIn().sleep(1) pass while el >= 0: BuiltIn().sleep(0.1) tmp_el = int(s2l.get_text(itemcount)) if el == tmp_el: break
def verify_network_set_network_untagged(cls, network, wait_timeout=5, fail_if_false=True): logger.debug("verify networkset networks untagged") ui_lib.wait_for_element( VerifyNetworkSetsElements.ID_VERIFY_NETWORK_SET_NETWORK_UNTAGGED % network, wait_timeout, fail_if_false)
def _wait_for_element(self, locator, timeout=5, fail_if_false=False): """Waits for an element to exist in the DOM Example: | Wait For Element | xpath="//a[text()='The link I want']" | | Wait For Element | xpath="//a[text()='The link I want']" | 10 | 0.2 | True """ ui_lib.wait_for_element(locator, timeout, fail_if_false)
def verify_volumeset_title(cls, volumeset, timeout=10, fail_if_false=True): """ On the Volume Sets Page, verify the title """ logger.info('verifying [ Volume Set title= %s ] is visible' % volumeset) ui_lib.wait_for_element(GeneralVolumeSetElements.ID_PAGE_LABEL, timeout=timeout, fail_if_false=fail_if_false)
def open_san_zoning_edit_dialog(): xpath_action = FusionSANPage.ID_SAN_ZONED_POLICY_EDIT try: ui_lib.wait_for_element(xpath_action, 10) except: pass logger._log_to_console_and_log_file("Open SAN Zoning Edit Dialog") ui_lib.move_to_element_and_click(xpath_action, xpath_action)
def wait_general_state_refreshing(cls, timeout=15, fail_if_false=True): ''' wait for general state = refreshing to show ''' logger.debug("wait general state show refreshing") ui_lib.wait_for_element(GeneralStoragePoolElements.ID_TEXT_GENERAL_STATE, timeout, fail_if_false) if ui_lib.wait_for_element_text(GeneralStoragePoolElements.ID_TEXT_GENERAL_STATE, "Refreshing", timeout, fail_if_false): return True else: return False
def _validate_adapter_information(hw_type, data_list): # Validating adapter tab information return_val = True selenium2lib = ui_lib.get_s2l() count_hw_types_row = selenium2lib._element_find( FusionServerHardwareTypePage.ID_ADAPTER_INFO_TABLE_ROW, False, False) if (len(count_hw_types_row) == len(data_list)): for i in range(len(count_hw_types_row)): row_data = [] row_content = len( selenium2lib._element_find( FusionServerHardwareTypePage. ID_ADAPTER_INFO_TABLE_SPECIFIC_ROW % str(i + 1), False, False)) # retrieving the data from the hardware types page. for l in range(row_content): ui_lib.wait_for_element( FusionServerHardwareTypePage. ID_ADAPTER_INFO_TABLE_SPECIFIC_ROW % str(i + 1), PerfConstants.DEFAULT_SYNC_TIME) row_data.append( str( selenium2lib._get_text( FusionServerHardwareTypePage. ID_ADAPTER_INFO_TABLE_SPECIFIC_CELL % (str(i + 1), str(l + 1))))) localflag = False # Comparing the retrieved values with each type information retrieved from the device. for listdat in data_list: if (row_data[1] in listdat[1]): if ((row_data[0] == listdat[0]) and (row_data[1] == listdat[1].strip('\r')) and (row_data[2] == listdat[2]) and (((row_data[3].replace(' ', '')).strip("/s")) == listdat[3]) and (row_data[4] == listdat[4])): localflag = True else: logger._log_to_console_and_log_file( "Server Hardware type adapter information is mismatching for the adapter: %s" % row_data[1]) if not localflag: return_val = False logger._warn( "Server Hardware type adapter information is mismatching for the type: %s" % hw_type) else: logger._log_to_console_and_log_file( "Server Hardware type adapter information is matching properly for the type: %s" % hw_type) else: return_val = False logger._warn( "Server Hardware type information is mismatching for the type: %s" % hw_type) return return_val
def verify_drives_view_drive_status(cls, drive): drive_bay = drive.bay drive_status = drive.status ui_lib.wait_for_element( DriveEnclosuresElements.ID_DRIVES_VIEW_STATUS_BY_BAY_NUMBER % (drive_bay, drive_status), fail_if_false=True) logger.info("Successfully verified that Drive: %s has Status: %s" % (drive_bay, drive_status))
def navigate_base(currentpage, menulink, itemcount): s2l = ui_lib.get_s2l() logger._log_to_console_and_log_file( 'Navigating to "{0}"'.format(currentpage)) if not s2l._is_element_present(currentpage): # open the menu and wait for it to be active if not s2l._is_element_present(FusionUIBaseElements.ID_MENU_ACTIVE): ui_lib.wait_for_element_and_click( FusionUIBaseElements.ID_MAIN_MENU_CONTROL, PerfConstants.DEFAULT_SYNC_TIME, fail_if_false=True) ui_lib.wait_for_element(FusionUIBaseElements.ID_MENU_ACTIVE, PerfConstants.DEFAULT_SYNC_TIME, fail_if_false=True) # if the new menu style is active, the link may lie under a collapsed section if not ui_lib.is_visible(menulink): ui_lib.wait_for_element_and_click( menulink + '/parent::li/parent::ul/parent::li') # click the menu link and wait for the page title ui_lib.wait_for_element_and_click(menulink, PerfConstants.DEFAULT_SYNC_TIME, fail_if_false=True) s2l.wait_until_page_contains_element(currentpage, PerfConstants.DEFAULT_SYNC_TIME) # if the menu is still opened, close it if ui_lib.is_visible(FusionUIBaseElements.ID_MENU_ACTIVE): ui_lib.wait_for_element_and_click( FusionUIBaseElements.ID_MAIN_MENU_CONTROL) ui_lib.wait_for_element_remove(FusionUIBaseElements.ID_MENU_ACTIVE) # wait for the page items to be displayed s2l.wait_until_page_contains_element(itemcount, PerfConstants.DEFAULT_SYNC_TIME) # added wait to remove int Base 10 conversion error while running with Selenium speed 0.0 BuiltIn().sleep(1) for x in range(1, 5): try: el = int(s2l.get_text(itemcount)) break except ValueError: BuiltIn().sleep(1) pass while el >= 0: BuiltIn().sleep(0.1) tmp_el = int(s2l.get_text(itemcount)) if el == tmp_el: break
def verify_bay_exists(cls, drive): drive_bay = drive.bay if drive.model == 'empty': ui_lib.wait_for_element( DriveEnclosuresElements.ID_EMPTY_DRIVE_BAY_BY_NUMBER % drive_bay, fail_if_false=True) else: ui_lib.wait_for_element( DriveEnclosuresElements.ID_DRIVE_BAY_BY_NUMBER % drive_bay, fail_if_false=True) logger.info("Successfully verified that bay %s exists" % drive_bay)
def verify_network_set_bandwidth(cls, prefb, maxb, wait_timeout=5, fail_if_false=True): logger.debug("verify networkset bandwidth") if ui_lib.wait_for_element( VerifyNetworkSetsElements.ID_VERIFY_NETWORK_SET_PREF_BANDWIDTH % prefb, wait_timeout, fail_if_false ) and ui_lib.wait_for_element( VerifyNetworkSetsElements.ID_VERIFY_NETWORK_SET_MAX_BANDWIDTH % maxb, wait_timeout, fail_if_false): return True else: return False
def verify_bay_status(cls, drive): drive_bay = drive.bay drive_status = drive.status if drive.model == 'empty': logger.info('Skipping verification of status for empty bay %s' % drive_bay) else: ui_lib.wait_for_element( DriveEnclosuresElements.ID_DRIVE_BAY_STATUS_BY_BAY_NUMBER % (drive_bay, drive_status), fail_if_false=True) logger.info( 'Successfully verified that Bay %s has expected Status: %s' % (drive_bay, drive_status))
def return_to_pspage(): """ Return to the PS page """ ui_lib.wait_for_element_and_click(i3sPlanScriptPage.ID_CANCEL_PS_BUTTON) if not ui_lib.wait_for_element(i3sPlanScriptPage.ID_PAGE_LABEL): ui_lib.fail_test("Failed to navigate to plan script page", True) return
def navigate(): """ Navigate to the Networks Page """ FusionUIBase.navigate_to_section(SectionType.NETWORKS) if not ui_lib.wait_for_element(FusionNetworksPage.ID_PAGE_LABEL): ui_lib.fail_test("Failed to navigate to network page", True)
def navigate(): base_page.navigate_base(i3sgoldenimagePage.ID_PAGE_LABEL, i3SBasePage.ID_MENU_LINK_GOLDEN_IMAGES, "css=span.hp-page-item-count") if not ui_lib.wait_for_element(i3sgoldenimagePage.ID_PAGE_LABEL): ui_lib.fail_test("Failed to navigate to Golden Image page", True)
def navigate(): """Navigate to settings page""" navigate_settings_base(FusionSettingsPage.ID_PAGE_LABEL, FusionUIBaseElements.ID_MENU_LINK_SETTINGS) if not ui_lib.wait_for_element(FusionSettingsPage.ID_PAGE_LABEL): ui_lib.fail_test("Failed to navigate to Settings page", True)
def shut_down(): """ Shut Down Shutdown the fusion appliance Example: | `Shut Down` | | """ if not ui_lib.wait_for_element(FusionSettingsPage.ID_PAGE_LABEL): navigate() logger._log_to_console_and_log_file("Shutdown Appliance") ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_MENU_ACTION_MAIN_BTN) ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_MENU_ACTION_SHUTDOWN) if ui_lib.wait_for_element_visible(FusionSettingsPage.ID_TEXT_SHUTDOWN): ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_YES_CONFIRM_SHUTDOWN) else: ui_lib.fail_test('Failed: The message while shutting down the appliance is not displayed') # Checking whether the fusion appliance started shutting down or not if ui_lib.wait_for_element_visible(FusionSettingsPage.ID_LABEL_WAITING, PerfConstants.RESTART_LABEL_VISIBLE): logger._log_to_console_and_log_file("The fusion appliance is getting shutdown") else: ui_lib.fail_test('Failed: The fusion appliance failed to shutdown') # Checking whether the fusion appliance is shut down or not if ui_lib.wait_for_element_visible(FusionSettingsPage.ID_LABEL_UNAVAILABLE, PerfConstants.STARTING_PROGRESS_VISIBLE): logger._log_to_console_and_log_file("The fusion appliance is shutdown successfully ") else: ui_lib.fail_test('Failed: The fusion appliance failed to shutdown the appliance in the restart procedure')
def navigate(): base_page.navigate_base(i3sDeploymentPlanPage.ID_PAGE_LABEL, i3SBasePage.ID_MENU_LINK_DEPLOYMENTPLANS, "css=span.hp-page-item-count") if not ui_lib.wait_for_element(i3sDeploymentPlanPage.ID_PAGE_LABEL): ui_lib.fail_test("Failed to navigate to OE Deployment page", True)
def verify_all_network_sets_not_found(cls, wait_timeout=20, fail_if_false=True): logger.debug("verify all network sets not found") return ui_lib.wait_for_element( VerifyNetworkSetsElements.ID_TABLE_NETWORK_SETS_NOT_FOUND, wait_timeout, fail_if_false)
def navigate(): """ Base navigate """ base_page.navigate_base(i3sPlanScriptPage.ID_PAGE_LABEL, i3SBasePage.ID_MENU_LINK_PLAN_SCRIPTS, "css=span.hp-page-item-count") if not ui_lib.wait_for_element(i3sPlanScriptPage.ID_PAGE_LABEL): ui_lib.fail_test("Failed to navigate to Plan Script page", True)
def get_enets_list(cls, timeout=5, fail_if_false=True): logger.debug("Get Enets List") enets_list = [] if ui_lib.wait_for_element(GeneralScopesElements.ID_TABLE_ENETS_LIST): enets_list = ui_lib.get_multi_elements_text( GeneralScopesElements.ID_TABLE_ENETS_LIST, timeout, fail_if_false) return enets_list