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 wait_delete_network_set_dialog_disappear(cls, wait_timeout=10, fail_if_false=True): logger.debug("wait delete network set dialog disappear") return ui_lib.wait_for_element_remove( DeleteNetworkSetsElements.ID_DIALOG_DELETE_NETWORK_SET, wait_timeout, fail_if_false)
def wait_delete_scope_dialog_close(cls, wait_timeout=10, fail_if_false=True): logger.debug("wait delete scope dialog close") return ui_lib.wait_for_element_remove( DeleteScopesElements.ID_DIALOG_DELETE_SCOPE, wait_timeout, fail_if_false)
def wait_edit_network_set_dialog_disappear(cls, wait_timeout=10, fail_if_false=True): logger.debug("wait edit network set dialog disappear") return ui_lib.wait_for_element_remove( EditNetworkSetsElements.ID_DIALOG_EDIT_NETWORK_SET, wait_timeout, fail_if_false)
def wait_add_network_dialog_disappear(cls, wait_timeout=5, fail_if_false=True): logger.debug("wait create network dialog disappear") return ui_lib.wait_for_element_remove( CreateNetworkSetsElements.ID_DIALOG_ADD_NETWORK, wait_timeout, fail_if_false)
def wait_create_scope_dialog_close(cls, wait_timeout=10, fail_if_false=True): logger.debug("wait create resource dialog close") return ui_lib.wait_for_element_remove( CreateScopesElements.ID_DIALOG_CREATE_SCOPE, wait_timeout, fail_if_false)
def remove_datacenter(*datacenter_obj): ''' remove_datacenter function to remove the datacenter from the appliance ''' logging._log_to_console_and_log_file("Removing datacenter") if isinstance(datacenter_obj, test_data.DataObj): datacenter_obj = [datacenter_obj] elif isinstance(datacenter_obj, tuple): datacenter_obj = list(datacenter_obj[0]) for datacenter in datacenter_obj: logging._log_to_console_and_log_file( "Removing datacenter with name.... %s" % datacenter.name) select_datacenter(datacenter.name) ui_lib.wait_for_element_and_click( FusionDataCenterPage.ID_ACTION_MAIN_BTN) ui_lib.wait_for_element_and_click( FusionDataCenterPage.ID_MENU_ACTION_REMOVE) ui_lib.wait_for_element_and_click( FusionDataCenterPage.ID_BTN_YES_REMOVE_CONFIRMATION) ui_lib.refresh_browser(FusionDataCenterPage.ID_MAIN_MENU, PerfConstants.DEFAULT_SYNC_TIME) if ui_lib.wait_for_element_remove( FusionDataCenterPage.ID_SELECT_DATACENTER % str(datacenter.name)): logging._log_to_console_and_log_file( "Datacenter with name %s Deleted" % datacenter.name) else: ui_lib.fail_test("Unable to Delete datacenter with name %s" % datacenter.name) return True
def verify_resource_deleted(cls, name, wait_timeout=10, fail_if_false=True): logger.debug("verify delete resource successful") return ui_lib.wait_for_element_remove( VerifyScopesElements.ID_ICON_REMOVE_RESOURCE % name, wait_timeout, fail_if_false)
def remove_unmanaged_device(*uds_obj): """ Delete Unmanaged device to appliance """ failed_times = 0 selenium2lib = ui_lib.get_s2l() if not ui_lib.wait_for_element(FusionUnmanagedDevicePage.ID_PAGE_LABEL): navigate() if isinstance(uds_obj, test_data.DataObj): uds_obj = [uds_obj] elif isinstance(uds_obj, tuple): uds_obj = list(uds_obj[0]) for uds in uds_obj: uds_list = [ui_lib.get_webelement_attribute("text", el) for el in selenium2lib._element_find(FusionUnmanagedDevicePage.ID_UDS_LIST_NAMES, False, False)] if uds.name not in uds_list: logger._warn("Unmanaged device '%s' does not exist" % uds.name) selenium2lib.capture_page_screenshot() failed_times = failed_times + 1 continue logger._log_to_console_and_log_file("-----------------------------") logger._log_to_console_and_log_file("Removing Unmanaged device %s" % uds.name) logger._log_to_console_and_log_file("-----------------------------") ui_lib.wait_for_element_and_click(FusionUnmanagedDevicePage.ID_ELEMENT_UNAMANGED_DEVICE_BASE % uds.name) ui_lib.wait_for_element_and_click(FusionUnmanagedDevicePage.ID_MENU_ACTION_MAIN_BTN) ui_lib.wait_for_element_and_click(FusionUnmanagedDevicePage.ID_MENU_ACTION_REMOVE) ui_lib.wait_for_element_and_click(FusionUnmanagedDevicePage.ID_BTN_REMOVE_UD_CONFIRM) ui_lib.wait_for_element_remove( FusionUnmanagedDevicePage.ID_ELEMENT_UNAMANGED_DEVICE_BASE % uds.name, PerfConstants.DEFAULT_SYNC_TIME) logger._log_to_console_and_log_file("Checking whether Unmanaged device %s is Deleted or not" % uds.name) ui_lib.wait_for_element_visible(FusionUnmanagedDevicePage.ID_LINK_CREATE_UD) uds_list = [ui_lib.get_webelement_attribute("text", el) for el in selenium2lib._element_find(FusionUnmanagedDevicePage.ID_UDS_LIST_NAMES, False, False)] if uds.name not in uds_list: logger._log_to_console_and_log_file("Unmanaged device '%s' removed successfully" % uds.name) else: ui_lib.fail_test(" The Unmanaged device '%s' not removed successfully" % uds.name) selenium2lib.capture_page_screenshot() failed_times = failed_times + 1 if failed_times > 0: return False else: return True
def delete_vCenter(vcen_name): """ delete vcenter Example: | `delete vCenter ` | ${vcen_name} | """ """ Navigate to vcenter Page """ if not ui_lib.wait_for_element(FusionvCenterPage.ID_PAGE_LABEL): navigate() logger._log_to_console_and_log_file( "Function call to remove selected vcenter") if not ui_lib.wait_for_element( FusionvCenterPage.ID_ELEMENT_VCENTER % vcen_name): logger.warn("vCenter %s not found in GUI" % vcen_name) return False logger._log_to_console_and_log_file("Deleting vCenter %s" % vcen_name) ui_lib.wait_for_element_and_click( FusionvCenterPage.ID_MENU_ACTION_MAIN_BTN) ui_lib.wait_for_element_and_click(FusionvCenterPage.ID_MENU_ACTION_REMOVE) ui_lib.wait_for_element_visible( FusionvCenterPage.ID_BTN_DELETE_VCENTER_CONFIRM, PerfConstants.DEFAULT_SYNC_TIME) ui_lib.wait_for_element_and_click( FusionvCenterPage.ID_BTN_DELETE_VCENTER_CONFIRM) "validating presence of vCenter in UI " logger._log_to_console_and_log_file( "Waiting for the element disappear from the UI") ui_lib.wait_for_element_remove( FusionvCenterPage.ID_ELEMENT_LIST % vcen_name, PerfConstants.REMOVE_VCENTER) ui_lib.wait_for_element_and_click(FusionvCenterPage.ID_RESET_FILTER, PerfConstants.DEFAULT_SYNC_TIME) if ui_lib.wait_for_element_notvisible( FusionvCenterPage.ID_ELEMENT_LIST % vcen_name, PerfConstants.REMOVE_VCENTER): logger._log_to_console_and_log_file( "Success: vCenter '{0}' is deleted".format(vcen_name)) return True else: logger.warn("Fail: Failed to delete vCenter: '{0}".format(vcen_name)) return False
def wait_progress_ongoing_disappear(cls, timeout=10, fail_if_false=True): ''' wait for progress bar to indicate complete ''' logger.debug("wait progress bar complete") if ui_lib.wait_for_element_remove(GeneralStoragePoolElements.ID_STATUS_NOTIFICATION_ONGOING, timeout, fail_if_false): return True else: return False
def delete_oedeploymentplan(self, *deleteoedeploymentplan_obj): """ Delete DeploymentPlan Example: | remove deploymentplan | ${oedpName} | """ s2l = ui_lib.get_s2l() """ Navigate to DeploymentPlan Page """ if not s2l._is_element_present(i3sDeploymentPlanPage.ID_PAGE_LABEL): navigate() ui_lib.wait_for_element(i3sDeploymentPlanPage.ID_DP_VISIBLE) """ Retrieve data from datasheet """ if type(deleteoedeploymentplan_obj) is test_data.DataObj: deleteoedeploymentplan_obj = [deleteoedeploymentplan_obj] elif type(deleteoedeploymentplan_obj) is tuple: deleteoedeploymentplan_obj = list(deleteoedeploymentplan_obj[0]) for oedp in deleteoedeploymentplan_obj: if s2l._page_contains(oedp.name): oedp_Obj = i3sDeploymentPlanPage.ID_ELEMENT_DEPLOYMENTPLAN % oedp.name s2l.mouse_over(oedp_Obj) ui_lib.wait_for_element_and_click( i3sDeploymentPlanPage.ID_ELEMENT_DEPLOYMENTPLAN % oedp.name) ui_lib.wait_for_element_and_click( i3sDeploymentPlanPage.ID_BUTTON_ACTION) if s2l._is_visible(i3sDeploymentPlanPage.ID_BUTTON_DELETE): logger._log_to_console_and_log_file( "Remove DeploymentPlan '%s'" % oedp.name) ui_lib.wait_for_element_and_click( i3sDeploymentPlanPage.ID_BUTTON_DELETE) if ui_lib.wait_for_element_visible( i3sDeploymentPlanPage.ID_DELETE_FORM): if (oedp.button == "delete"): ui_lib.wait_for_element_and_click( i3sDeploymentPlanPage.ID_YES_DELETE_BUTTON) elif (oedp.button == "cancel"): ui_lib.wait_for_element_and_click( i3sDeploymentPlanPage.ID_CANCEL_DELETE_BUTTON) logger._log_to_console_and_log_file( " Deploymentplan '%s' not deleted as Cancel was chosen" % oedp.name) continue else: logger._warn("Form is not visible") continue if ui_lib.wait_for_element_remove( i3sDeploymentPlanPage.ID_ELEMENT_DEPLOYMENTPLAN % str(oedp.name), PerfConstants.REMOVE_SERVER): logger._log_to_console_and_log_file( "Removed Deploymentplan '%s'" % oedp.name) else: logger._warn( "FAILED :: Deploymentplan can't be removed - '%s'" % oedp.name) else: logger._warn( "'%s' Deploymentplan can't be deleted, delete option is not visible on page." % oedp.name) else: logger._warn( "'%s' Deploymentplan not found in Deploymentplan page" % oedp.name) continue return
def wait_edit_scope_dialog_close(cls, wait_timeout=10, fail_if_false=True): logger.debug("wait edit scope dialog close") return ui_lib.wait_for_element_remove( EditScopesElements.ID_DIALOG_EDIT_SCOPE, wait_timeout, fail_if_false)
def create_fcoe_network(*net_obj): """ Create FCoE Network Arguments: name* -- Name of FCoE network as a string. vlan -- VLAN ID string. Set only if vlan_tag is 'Tagged'. maxbandswdth -- Maximum bandwidth. Should be greater than 'preferredbw' argument. Defaults to 10 Gb/s. preferredbw -- Preferred Bandwidth. Defaults to 2.5 Gb/s. san -- Associated SAN. * Required Arguments Example: <myNetworks> <network name="300" vlan="300" maxbandwdth="10" san="wpstsw9_FID120-10:00:00:27:f8:2e:e8:98"/> </myNetworks> """ s2l = ui_lib.get_s2l() if not ui_lib.wait_for_element(FusionNetworksPage.ID_PAGE_LABEL): navigate() logger._log_to_console_and_log_file("Create FCoE network") if isinstance(net_obj, test_data.DataObj): net_obj = [net_obj] elif isinstance(net_obj, tuple): net_obj = list(net_obj[0]) ui_lib.wait_for_element_and_click( FusionNetworksPage.ID_LINK_CREATE_NETWORK) ui_lib.wait_for_element(FusionNetworksPage.ID_INPUT_NETWORK_NAME) for net in net_obj: logger._log_to_console_and_log_file("") # Set network Name ui_lib.wait_for_element_and_input_text( FusionNetworksPage.ID_INPUT_NETWORK_NAME, net.name) # Select Ethernet Type s2l.select_checkbox(FusionNetworksPage.ID_RADIO_FCOE_TYPE) # Associating SAN with network for automation of zoning on the networks if not (net.san).upper() == "": ui_lib.wait_for_element_and_click( FusionNetworksPage.ID_COMBO_ASSOCIATE_SAN) CreateNetworks.input_select_associate_with_san(net.san) else: logger._log_to_console_and_log_file("SAN not specified") if net.has_property("vlan"): ui_lib.wait_for_element_and_input_text( FusionNetworksPage.ID_INPUT_NETWORK_VLAND_ID, net.vlan) else: ui_lib.fail_test("Vlan ID not specified.") # Set Preferred bandwidth if net.has_property('preferredbw'): net.preferredbw = float(net.preferredbw) if not ((net.preferredbw >= BW_MIN) and (net.preferredbw <= BW_MAX)): ui_lib.fail_test( "Invalid Preferred Bandwidth value specified (%s). Should be between %s and %s" % (net.preferredbw, BW_MIN, BW_MAX)) else: ui_lib.wait_for_element_and_input_text( FusionNetworksPage.ID_INPUT_NETWORK_PREF_BANDWIDTH, str(net.preferredbw)) else: # Use Default Bandwidth value net.preferredbw = float(DEFAULT_PREFERRED_BW) # Set Max bandwidth if net.has_property('maxbandwdth'): net.maxbandwdth = float(net.maxbandwdth) if not ((net.maxbandwdth >= BW_MIN) and (net.maxbandwdth <= BW_MAX)): ui_lib.fail_test( "Invalid Max Bandwidth value specified (%s). Should be between %s and %s" % (net.maxbandwdth, BW_MIN, BW_MAX)) elif not net.maxbandwdth >= net.preferredbw: ui_lib.fail_test( "Invalid Max Bandwidth value specified (%s). Should be greater than Preferred Bandwidth (%s)" % (net.maxbandwdth, net.preferredbw)) else: ui_lib.wait_for_element_and_input_text( FusionNetworksPage.ID_INPUT_NETWORK_MAXS_BANDWIDTH, str(net.maxbandwdth)) # Click on the create plus button s2l.click_button(FusionNetworksPage.ID_BTN_CREATE_NETWORK_PLUS) s2l.page_should_not_contain("Failed to add fcoe network") if s2l._page_contains("Unable to add fcoe network"): ui_lib.fail_test("Unable to add fcoe network '{0}': {1}".format( net.name, s2l._get_text( FusionNetworksPage.ID_CREATE_NETWORK_MESSAGE_DETAILS))) else: logger._log_to_console_and_log_file( "Successfully created FCOE network %s" % net.name) ui_lib.wait_for_condition(lambda: s2l._get_value( FusionNetworksPage.ID_INPUT_NETWORK_NAME) == "", fail_if_false=True) # Close Network Dialog s2l.click_button(FusionNetworksPage.ID_BTN_CLOSE_NETWORK) ui_lib.wait_for_element_remove(FusionNetworksPage.ID_CREATE_NETWORK_DIALOG) # perform validation if required if test_data.get_variable("Validate"): validate_network_exists(net_obj, fail_if_false=False)
def delete_goldenimage(self, *removegoldenimage_obj): """ Select Delete Golden Image Example: | Edit GoldenImage | | """ s2l = ui_lib.get_s2l() s2l = ui_lib.get_s2l() error = 0 return_data = "" """ Navigate to Golden Image Page """ if not s2l._is_element_present(i3sgoldenimagePage.ID_PAGE_LABEL): navigate() ui_lib.wait_for_element(i3sgoldenimagePage.ID_GI_VISIBLE_SELECT) """ Retrieve data from datasheet """ if type(removegoldenimage_obj) is test_data.DataObj: removegoldenimage_obj = [removegoldenimage_obj] elif type(removegoldenimage_obj) is tuple: removegoldenimage_obj = list(removegoldenimage_obj[0]) logging._log_to_console_and_log_file(type(removegoldenimage_obj)) for gi in removegoldenimage_obj: if s2l._page_contains(gi.name): gi_Obj = i3sgoldenimagePage.ID_ELEMENT_GI % gi.name s2l.mouse_over(gi_Obj) ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_ELEMENT_GI % gi.name) ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_BUTTON_ACTION) if s2l._is_visible(i3sgoldenimagePage.ID_BUTTON_REMOVE): logger._log_to_console_and_log_file( "Remove Golden Image '%s'" % gi.name) ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_BUTTON_REMOVE) if ui_lib.wait_for_element_visible( i3sgoldenimagePage.ID_DELETE_FORM ): # Wait for GI form to visible if (gi.button == "Remove"): ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_YES_REMOVE_BUTTON) if ui_lib.wait_for_element_visible( i3sgoldenimagePage.GI_PAGE_NOTIFICATION): ui_lib.wait_for_element_and_click( i3sgoldenimagePage.GI_REMOVE_ERROR2) error2 = s2l._get_text( i3sgoldenimagePage.GI_REMOVE_ERROR2_OBJ) logger._log_to_console_and_log_file( "Failure Error: '%s'" % error2) logger._warn("Failed to remove Golden Image") continue elif (gi.button == "Cancel"): ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_CANCEL_DELETE_BUTTON) logger._log_to_console_and_log_file( " Golden Image '%s' not deleted as Cancel was chosen" % gi.name) continue else: logger._warn("Golden Image is not visible") continue # validating Golden Image removal if ui_lib.wait_for_element_remove( i3sgoldenimagePage.ID_ELEMENT_GI % str(gi.name), PerfConstants.REMOVE_SERVER): logger._log_to_console_and_log_file( "Removed Golden Image '%s'" % gi.name) else: logger._warn( "FAILED :: Golden Image can't be removed - '%s'" % gi.name) else: logger._warn( "'%s' Golden Image can't be deleted, Remove option is not visible on page." % gi.name) else: logger._warn("'%s' Golden Image not found in Golden Image page" % gi.name) continue return
def edit_goldenimage(self, *editgoldenimage_obj): """ Select Edit Golden Image Example: | Edit GoldenImage | | """ s2l = ui_lib.get_s2l() error = 0 return_data = "" """ Navigate to Golden Image Page """ if not s2l._is_element_present(i3sgoldenimagePage.ID_PAGE_LABEL): navigate() ui_lib.wait_for_element(i3sgoldenimagePage.ID_GI_VISIBLE_SELECT) """ Retrieve data from datasheet """ if type(editgoldenimage_obj) is test_data.DataObj: editgoldenimage_obj = [editgoldenimage_obj] elif type(editgoldenimage_obj) is tuple: editgoldenimage_obj = list(editgoldenimage_obj[0]) logging._log_to_console_and_log_file(type(editgoldenimage_obj)) for gi in editgoldenimage_obj: if s2l._page_contains(gi.nameedit): gi_obj = i3sgoldenimagePage.ID_ELEMENT_GI % gi.nameedit s2l.mouse_over(gi_obj) ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_ELEMENT_GI % gi.nameedit) ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_BUTTON_ACTION) if s2l._is_visible(i3sgoldenimagePage.ID_BUTTON_EDIT): logger._log_to_console_and_log_file("Edit Golden Image '%s'" % gi.name) ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_BUTTON_EDIT) ''' Below are flags to track invalid inputs''' name_flag = 1 desc_flag = 1 dup_name_flag = 0 special_char_flag = 0 non_exis_gi_flag = 0 logger._log_to_console_and_log_file("gi is " + str(gi)) ''' In the below code, flags are set/unset based on the validity of the input parameters''' if (gi.name == "" or len(gi.name) > 255): name_flag = 0 if (gi.description == "" or len(gi.description) > 1024): desc_flag = 0 """ Before Adding check for the Golden Image exists """ logger._log_to_console_and_log_file(" name_flag is" + str(name_flag)) if name_flag: logger._log_to_console_and_log_file("inside name flag") if s2l._is_element_present(i3sgoldenimagePage.ID_ELEMENT_GI % gi.nameedit): ''' set dup_name_flag to true if name already exists''' dup_name_flag = 1 logger._log_to_console_and_log_file(" dup name") logger._log_to_console_and_log_file(" name_flag is" + str(name_flag)) ui_lib.wait_for_element_and_input_text( i3sgoldenimagePage.ID_INPUT_EDIT_NAME, gi.name) if desc_flag: ui_lib.wait_for_element_and_input_text( i3sgoldenimagePage.ID_INPUT_EDIT_DESCRIPTION, gi.description) logger._log_to_console_and_log_file("inside desc flag") if (gi.button != "cancel"): if (gi.button == "OK"): logger._log_to_console_and_log_file("inside Edit loop") ui_lib.wait_for_element_visible( i3sgoldenimagePage.ID_EDIT_OK_BUTTON) ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_EDIT_OK_BUTTON) '''checking for blank name error message''' if (name_flag == 0 and len(gi.name) > 255 and desc_flag == 0 and len(gi.description)): if ui_lib.wait_for_element_visible( i3sgoldenimagePage.ID_ERROR_FORM): text = ui_lib.get_text(i3sgoldenimagePage.ID_ERROR_FORM) if len( ui_lib.get_text(i3sgoldenimagePage.ID_ERROR_FORM). strip()) == 0: logger._warn('Blank error form') elif (text != error_messages.GI_EDIT_INVALID_NAME_MESSAGE): logger._warn( "Error message displayed doesn't match the invalid golden image error message" ) logger._log_to_console_and_log_file( "Error message is" + str(text)) if not ui_lib.wait_for_element_visible( i3sgoldenimagePage.ID_ERROR_LABEL): text = ui_lib.get_text(i3sgoldenimagePage.ID_ERROR_LABEL) if len( ui_lib.get_text(i3sgoldenimagePage.ID_ERROR_LABEL). strip()) == 0: logger._warn('Blank label in the panel') elif (text != error_messages.GI_EDIT_DUPLICATE_NAME_MESSAGE): logger._warn( "Label displayed doesn't match the invalid golden image label" ) logger._log_to_console_and_log_file( "Error message is" + str(text)) logger._log_to_console_and_log_file("inside blank desc") if ui_lib.wait_for_element_visible( i3sgoldenimagePage.ID_ERROR_LABEL): text = ui_lib.get_text(i3sgoldenimagePage.ID_ERROR_LABEL) if len( ui_lib.get_text(i3sgoldenimagePage.ID_ERROR_LABEL). strip()) == 0: logger._warn('Blank label in the panel') elif (text != error_messages.GI_ADD_EMPTY_DESCRIPTION_MESSAGE): logger._warn( "Label displayed doesn't match the invalid golden image description label" ) logger._log_to_console_and_log_file( "Error message is" + str(text)) return_to_edit_goldenimage() continue '''Duplicate Name''' if (dup_name_flag == 0): logger._log_to_console_and_log_file( "inside dup name flag loop") if ui_lib.wait_for_element_visible( i3sgoldenimagePage.ID_ERROR_FORM): text = ui_lib.get_text(i3sgoldenimagePage.ID_ERROR_FORM) if len( ui_lib.get_text(i3sgoldenimagePage.ID_ERROR_FORM). strip()) == 0: logger._warn('Blank error form') elif (text != error_messages.GI_EDIT_DUPLICATE_NAME_MESSAGE): logger._warn( "Error message displayed doesn't match the duplicate golden image error message" ) logger._log_to_console_and_log_file( "Error message is" + str(text)) return_to_edit_goldenimage() continue '''Changed GI_INVALID_INPUT_* to GI_INVALID_NAME_*''' if (special_char_flag == 0): logger._log_to_console_and_log_file( "inside Invalid Characters name flag loop") if ui_lib.wait_for_element_visible( i3sgoldenimagePage.ID_ERROR_FORM): text = ui_lib.get_text(i3sgoldenimagePage.ID_ERROR_FORM) if len( ui_lib.get_text(i3sgoldenimagePage.ID_ERROR_FORM). strip()) == 0: logger._warn('Blank error form') elif (text != error_messages.GI_EDIT_INVALID_NAME_MESSAGE): logger._warn( "Error message displayed doesn't match the duplicate golden image error message" ) logger._log_to_console_and_log_file( "Error message is" + str(text)) return_to_edit_goldenimage() continue logging._log_to_console_and_log_file( "\n Editing Golden Image please wait ...\n") if ui_lib.wait_for_element_remove( i3sgoldenimagePage.ID_ELEMENT_GI % str(gi.nameedit), PerfConstants.REMOVE_SERVER): logger._log_to_console_and_log_file( "Edited Golden Image '%s'" % gi.nameedit) else: logger._warn("FAILED :: Golden Image can't be edited - '%s'" % gi.name) ''' To continue to next scenario, we need to have the Add page displayed ''' if (gi.button == 'OK'): if ui_lib.wait_for_element(i3sgoldenimagePage.ID_ELEMENT_GI % gi.nameedit): logger._log_to_console_and_log_file( "Golden Image '%s' Edited successfully" % gi.name) logger._log_to_console_and_log_file( "inside Edit button loop") ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_BUTTON_ACTION) if s2l._is_visible(i3sgoldenimagePage.ID_BUTTON_EDIT): logger._log_to_console_and_log_file( "Edit Golden Image '%s'" % gi.name) ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_BUTTON_EDIT) continue else: logger._warn("Editing golden image %s failed" % gi.name) continue elif (gi.button == 'cancel'): logger._log_to_console_and_log_file("inside cancel flag loop") ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_CANCEL_EDIT_BUTTON) if not ui_lib.wait_for_element( i3sgoldenimagePage.ID_PAGE_LABEL): logger._warn( "Failed to navigate to Edit Golden Image page") else: if not ui_lib.wait_for_element_visible( i3sgoldenimagePage.ID_ELEMENT_GI): logger._log_to_console_and_log_file( "Golden Image '%s' not Edited " % gi.nameedit) else: logger._warn("Golden Image '%s' Edited " % gi.name) if ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_BUTTON_ACTION): ui_lib.wait_for_element_and_click( i3sgoldenimagePage.ID_BUTTON_EDIT) ui_lib.wait_for_element_visible( i3sgoldenimagePage.ID_EDIT_FORM) logger._log_to_console_and_log_file( "Clicked on Edit GI button") return_to_edit_goldenimage() continue return
def delete_planscript(*deleteplanscript_obj): """ Delete PlanScript Example: | remove planscript | ${psName} | """ s2l = ui_lib.get_s2l() """ Navigate to Plan script Page """ if not s2l._is_element_present(i3sPlanScriptPage.ID_PAGE_LABEL): navigate() ui_lib.wait_for_element(i3sPlanScriptPage.ID_PS_VISIBLE) """ Retrieve data from datasheet """ if type(deleteplanscript_obj) is test_data.DataObj: deleteplanscript_obj = [deleteplanscript_obj] elif type(deleteplanscript_obj) is tuple: deleteplanscript_obj = list(deleteplanscript_obj[0]) for ps in deleteplanscript_obj: if s2l._is_element_present(i3sPlanScriptPage.ID_ELEMENT_PS % ps.name): # logger._log_to_console_and_log_file("Remove Planscript '%s'" % ps.name) ps_obj = i3sPlanScriptPage.ID_ELEMENT_PS % ps.name s2l.mouse_over(ps_obj) ui_lib.wait_for_element_and_click(i3sPlanScriptPage.ID_ELEMENT_PS % ps.name) ui_lib.wait_for_element_and_click( i3sPlanScriptPage.ID_BUTTON_ACTION) if s2l._is_visible(i3sPlanScriptPage.ID_ACTION_DELETE_BUTTON): # logger._log_to_console_and_log_file("Remove Planscript '%s'" % ps.name) ui_lib.wait_for_element_and_click( i3sPlanScriptPage.ID_ACTION_DELETE_BUTTON) if ui_lib.wait_for_element_visible( i3sPlanScriptPage.ID_DELETE_FORM ): # Wait for form to be visible if ps.button == "delete": ret_status = ui_lib.wait_for_element_and_click( i3sPlanScriptPage.ID_DELETE_BUTTON_YES) print ret_status # logger._log_to_console_and_log_file(ret_status) if ret_status == "False": logger._log_to_console_and_log_file( "Plan script '%s' not deleted " % ps.name) elif ps.button == "cancel": ui_lib.wait_for_element_and_click( i3sPlanScriptPage.ID_DELETE_BUTTON_CANCEL) # logger._log_to_console_and_log_file("Plan script '%s' not deleted as Cancel was chosen" % ps.name) continue else: logger._warn("Form is not visible") continue # validating Plan script removal if ui_lib.wait_for_element_remove( i3sPlanScriptPage.ID_ELEMENT_PS % str(ps.name), PerfConstants.REMOVE_SERVER): logger._log_to_console_and_log_file( "Removed Plan script '%s'" % ps.name) else: logger._warn( "FAILED :: Plan script can't be removed - '%s'" % ps.name) else: logger._warn( "'%s' Plan script can't be deleted, delete option is not visible on page." % ps.name) else: logger._warn("'%s' Plan script not found in Plan script page" % ps.name) continue return
def wait_progress_bar_disappear(cls, timeout=5, fail_if_false=True): logger.debug("waiting for progress bar to disappear") return ui_lib.wait_for_element_remove( Updateapplianceelements.ID_VIEW_UPDATE_PROGRESS, timeout, fail_if_false)
def check_user_privileges(user_name): s2l = ui_lib.get_s2l() if not ui_lib.wait_for_element(FusionLSGPage.ID_PAGE_LABEL): navigate() user = test_data.get_privilege_by_name(user_name) logger._log_to_console_and_log_file("Create logical switch groups for %s" % user_name) if ((user.create).lower() == "yes"): logger._info("should pass") if ui_lib.wait_for_element_and_click( FusionLSGPage.ID_LINK_CREATE_LOGICAL_SWITCH_GROUP): ui_lib.wait_for_element_and_click(FusionLSGPage.ID_BTN_CLOSE_LSG) ui_lib.wait_for_element_remove(FusionLSGPage.ID_CREATE_LSG_DIALOG) logger._log_to_console_and_log_file( "Successfully clicked create Logical Switch Groups") else: return False else: logger._log_to_console_and_log_file("should fail") if not ui_lib.wait_for_element_and_click( FusionLSGPage.ID_LINK_CREATE_LOGICAL_SWITCH_GROUP): logger._log_to_console_and_log_file( "Create LSG button not visible as expected") else: return False logger._log_to_console_and_log_file("Read logical switch groups for %s" % user_name) if ((user.read).lower() == "yes"): logger._log_to_console_and_log_file("should pass") if ui_lib.wait_for_element_visible( FusionLSGPage.ID_ELEMENT_LSG_NAME_BASE % user.lsgname, PerfConstants.DEFAULT_SYNC_TIME): select_lsg(user.lsgname) logger._log_to_console_and_log_file( "Able to Read logical switch groups for %s" % user.lsgname) else: return False else: logger._log_to_console_and_log_file("should fail") if not ui_lib.wait_for_element_visible( FusionLSGPage.ID_ELEMENT_LSG_NAME_BASE % user.lsgname, PerfConstants.DEFAULT_SYNC_TIME): logger._log_to_console_and_log_file( "Unable to Read logical switch groups as expected") else: return False logger._log_to_console_and_log_file("Update logical switch groups for %s" % user_name) if ((user.update).lower() == "yes"): logger._log_to_console_and_log_file("should pass") select_lsg(user.lsgname) if ui_lib.wait_for_element_and_click(FusionLSGPage.ID_ACTION_MAIN_BTN): if ui_lib.wait_for_element_and_click( FusionLSGPage.ID_ACTION_MENU_EDIT_LSG): ui_lib.wait_for_element_and_input_text( FusionLSGPage.ID_INPUT_EDIT_LSGNAME, user.newName) ui_lib.wait_for_element_and_click( FusionLSGPage.ID_BTN_EDIT_CANCEL) logger._log_to_console_and_log_file( "Able to Edit logical switch groups") else: return False else: return False else: logger._log_to_console_and_log_file("should fail") if not ui_lib.wait_for_element_and_click( FusionLSGPage.ID_ACTION_MAIN_BTN): logger._log_to_console_and_log_file( "Unable to Edit logical switch groups as expected") else: return False logger._log_to_console_and_log_file("Delete logical switch groups for %s" % user_name) if ((user.delete).lower() == "yes"): logger._log_to_console_and_log_file("should pass") select_lsg(user.lsgname) if ui_lib.wait_for_element_and_click(FusionLSGPage.ID_ACTION_MAIN_BTN): if ui_lib.wait_for_element_and_click( FusionLSGPage.ID_ACTION_MENU_DELETE_LSG): logger._log_to_console_and_log_file( "Able to delete logical switch groups") else: return False else: return False else: logger._log_to_console_and_log_file("should fail") if not ui_lib.wait_for_element_and_click( FusionLSGPage.ID_ACTION_MAIN_BTN): logger._log_to_console_and_log_file( "Unable to delete logical switch groups as expected") else: return False return True
def delete_power_delivery_device(*pdd_obj): """ This function is to delete power delivery device delete_power_delivery_device Example: fusion ui delete power delivery device @{TestData.powerdeliverydevices} """ failed_times = 0 s2l = ui_lib.get_s2l() """ Navigate to Power Delivery Device Page """ if not s2l._is_element_present( FusionPowerDeliveryDevicePage.ID_PAGE_LABEL): navigate() if isinstance(pdd_obj, test_data.DataObj): pdd_obj = [pdd_obj] elif isinstance(pdd_obj, tuple): pdd_obj = list(pdd_obj[0]) for pddevice in pdd_obj: ui_lib.wait_for_element( FusionPowerDeliveryDevicePage.ID_POWER_DELIVERY_DEVICE_LIST) """ Getting the hp intelligent power distribution unit name on providing the ip """ if (pddevice.type).lower() == "hp intelligent power distribution unit": if pddevice.has_property('force') and ( pddevice.force).lower() == "true": pddhp_pdu_obj = "xpath=//*/tbody//td[contains(text(), '%s')][1]" ui_lib.wait_for_element_visible(pddhp_pdu_obj % pddevice.ip) pddhp_pdu = s2l._get_text(pddhp_pdu_obj % pddevice.ip) pddevice.name = (pddhp_pdu).strip() else: continue """ Selecting and deleting the Power Delivery Device """ logger._log_to_console_and_log_file( "************** Deleting Power Delivery Device %s ********** " % pddevice.name) if not select_power_delivery_device(pddevice.name): logger._warn("Failed to select PDU %s" % pddevice.name) s2l.capture_page_screenshot() failed_times += 1 continue else: ui_lib.wait_for_element_and_click( FusionPowerDeliveryDevicePage.ID_ACTION_MAIN_BTN) ui_lib.wait_for_element_and_click( FusionPowerDeliveryDevicePage.ID_ACTION_MENU_DELETE_PDD) ui_lib.wait_for_element_and_click( FusionPowerDeliveryDevicePage.ID_BTN_CONFIRM_DELETE) ui_lib.wait_for_element_remove( FusionPowerDeliveryDevicePage.ID_ELEMENT_PDD_NAME_BASE % pddevice.name) """ validation after deletion """ ui_lib.wait_for_element( FusionPowerDeliveryDevicePage.ID_POWER_DELIVERY_DEVICE_LIST) ui_lib.wait_for_element_remove( FusionPowerDeliveryDevicePage.ID_ELEMENT_PDD_NAME_BASE % pddevice.name, PerfConstants.DEFAULT_SYNC_TIME) ui_lib.wait_for_element_notvisible( FusionPowerDeliveryDevicePage.ID_ELEMENT_PDD_NAME_BASE % pddevice.name, PerfConstants.REMOVE_PDD_TIME) logger._log_to_console_and_log_file( "Checking for pdd %s in the UI after deleting" % pddevice.name) if not (s2l._is_element_present( FusionPowerDeliveryDevicePage.ID_ELEMENT_PDD_NAME_BASE % pddevice.name)): logger._log_to_console_and_log_file( '%s pdd deleted successfully' % pddevice.name) else: ui_lib.fail_test( " The Power Delivery Device " + pddevice.name + " not deleted successfully", "True") s2l.capture_page_screenshot() failed_times += 1 if failed_times > 0: return False else: return True
def verify_network_deleted(cls, name, wait_timeout=10, fail_if_false=True): logger.debug("verify delete network successful") return ui_lib.wait_for_element_remove( VerifyNetworkSetsElements.ID_BUTTON_REMOVE_NETWORK % name, wait_timeout, fail_if_false)
def wait_for_element_remove(self, locator, timeout=5, fail_if_false=False): """Waits for an element to be removed from the DOM Example: | Wait For Element Remove | xpath="//a[text()='The link I want']" | """ return ui_lib.wait_for_element_remove(locator, timeout, fail_if_false)