def wait_applying_network_settings_progress_bar_disappear( cls, timeout=1000, fail_if_false=True): logger.debug( "wait edit applying network settings progress bar disappear") ui_lib.wait_for_element_notvisible( C7000_EditNetworkingElements. ID_PROGRESS_BAR_APPLYING_NETWORK_SETTINGS, timeout, fail_if_false)
def wait_time_and_local_panel_disappear(cls, timeout=5, fail_if_false=True): logger.debug("wait for time and local panel is disappeared") ui_lib.wait_for_element_notvisible( GeneralTimeAndLocaleElements.ID_TEXT_TIME_AND_LOCALE, timeout, fail_if_false)
def wait_edit_time_and_locale_dialog_disappear(cls, timeout=5, fail_if_false=True): logger.debug("wait edit time and locale dialog disappear") ui_lib.wait_for_element_notvisible( EditTimeAndLocaleElements.ID_DIALOG_EDIT_TIME_AND_LOCALE, timeout, fail_if_false)
def restore_from_backup(backupdirectory): """ Restore From Backup : restore backup for fusion appliance, NOTE : This code is dependent on download_backup function, execute download_backup then go for restore_from_backup PRE-REQUISITES : > AutoIT used to upload back-up file to the appliance. Steps to configure AUTOIT, 1. Download autoit-v3-setup and pywin32-218.win-amd64-py2.7 (or pywin32-214.win32-py2.7) to your system 2. register AUTOITX3 , type on cmd prompt: C:\Program Files (x86)\AutoIt3\AutoItX>regsvr32 AutoItX3_x64.dll OR C:\Program Files (x86)\AutoIt3\AutoItX>regsvr32 AutoItX3.dll 3. Download and install AUTOIT module from robot framework website. """ s2l = ui_lib.get_s2l() if not ui_lib.wait_for_element(FusionSettingsPage.ID_PAGE_LABEL): navigate() logger._log_to_console_and_log_file("Restore Backup") ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_MENU_ACTION_MAIN_BTN) ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_MENU_ACTION_RESTORE_FROM_BACKUP) ui_lib.wait_for_element_visible(FusionSettingsPage.ID_BTN_BROWSE_FILE, PerfConstants.RESTORE_BACKUP_CHOOSE_FILE) logger._log_to_console_and_log_file("Choose the restore backup file , " + backupdirectory + " from the path specified") # chooses the specific file for files in os.listdir(backupdirectory): filenamewithpath = os.path.join(backupdirectory, files) logger._log_to_console_and_log_file("File Name, along with the path %s" % filenamewithpath) if not filenamewithpath: ui_lib.fail_test("Failed to find backup file ", True) s2l.choose_file(FusionSettingsPage.ID_BTN_BROWSE_FILE, filenamewithpath) ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_BROWSE_FILE) # AutoIT code to click on open button # if os.name == "nt": # autoit = win32com.client.Dispatch("AutoItX3.Control") # autoit.ControlClick("File Upload", "", "Button1") s2l.wait_until_page_contains("This file is compatible", PerfConstants.FILE_COMPATIBILITY_CHECK) logger._log_to_console_and_log_file("uploaded backup file") s2l.select_checkbox(FusionSettingsPage.ID_CHECKBOX_RESTORE_CONFIRMATION) ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_RESTORE_FROM_BACKUP) # need to confirm, by clicking the restore from backup button again ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_RESTORE_FROM_BACKUP) # waiting for restore to finish ui_lib.wait_for_element(FusionSettingsPage.ID_LABEL_RESTORING_FROM_BACKUP, PerfConstants.RESTORING_LABEL_VISIBLE) ui_lib.wait_for_element_notvisible(FusionSettingsPage.ID_LABEL_RESTORING_FROM_BACKUP, PerfConstants.RESTORING_LABEL_VISIBLE) ui_lib.wait_for_element(FusionSettingsPage.ID_LABEL_RESTORING, PerfConstants.RESTORING_LABEL_VISIBLE) ui_lib.wait_for_element_notvisible(FusionSettingsPage.ID_LABEL_RESTORING, PerfConstants.RESTORE_DATA_FROM_BACKUP_TIME) logger._log_to_console_and_log_file("Restore Completed, checking if the login page is visible.") # final check for login page existence ui_lib.wait_for_element(FusionLoginPage.ID_BTN_LOGIN_BUTTON) logger._log_to_console_and_log_file("Restore Successful for Fusion Appliance")
def verify_drive_enclosure_not_exist(cls, drive_enclosure, timeout=10, fail_if_false=True): logger.info("verify [ DRIVE ENCLOSURE '%s' ] is not existing" % drive_enclosure) ui_lib.wait_for_element_notvisible( DriveEnclosuresElements.ID_TABLE_DRIVE_ENCLOSURES % drive_enclosure, timeout, fail_if_false)
def wait_until_uid_off(cls, drive_enclosure_name, timeout, fail_if_false=True): logger.debug( "waiting for drive_enclosure UID '%s' status to go off ..." % drive_enclosure_name) ui_lib.wait_for_element_notvisible( DriveEnclosuresElements.ID_STATUS_UID_LIGHT_ON, timeout, fail_if_false=True)
def close_guided_setup_panel(): """ hide the guided setup panel """ if not logged_in(): raise AssertionError("Not logged in") # if the panel not already hidden, close it if ui_lib.is_visible(FusionUIBaseElements.ID_GUIDED_SETUP_PANEL): ui_lib.wait_for_element_and_click( FusionUIBaseElements.ID_GUIDED_SETUP_BUTTON) ui_lib.wait_for_element_notvisible( FusionUIBaseElements.ID_GUIDED_SETUP_PANEL, fail_if_false=True)
def wait_edit_san_manager_dialog_disappear(cls, timeout=5, fail_if_false=True): logger.debug("waiting for edit san manager dialog to disappear") return ui_lib.wait_for_element_notvisible( EditSANMangersElements.ID_DIALOG_EDIT_SAN_MANAGER, timeout, fail_if_false)
def verify_dashboard_panels_removed(cls, dashboard_panel, timeout=5, fail_if_false=False): logger.debug("verify dashboard panels removed [%s]" % dashboard_panel) if not ui_lib.wait_for_element_notvisible(GeneralDashboardElements.ID_DASHBOARD_PANEL % dashboard_panel, timeout, fail_if_false): logger.warn("[%s] has not been removed!" % dashboard_panel) return False else: return True
def wait_add_resources_dialog_close(cls, wait_timeout=5, fail_if_false=True): logger.debug("wait add resources dialog close") return ui_lib.wait_for_element_notvisible( EditScopesElements.ID_DIALOG_ADD_RESOURCE, wait_timeout, fail_if_false)
def verify_create_scope_button_not_exist(cls, timeout=5, fail_if_false=True): logger.debug("verify create Scope button is not existed") return ui_lib.wait_for_element_notvisible( CreateScopesElements.ID_BUTTON_CREATE_SCOPE, timeout, fail_if_false)
def wait_delete_logical_switch_group_dialog_close(cls, timeout=5, fail_if_false=True): logger.debug("waiting for dialog 'Delete Logical Switch Group' to close ...") if ui_lib.wait_for_element_notvisible(cls.e.ID_DIALOG_DELETE_LOGICAL_SWITCH_GROUP, timeout=timeout, fail_if_false=fail_if_false): logger.debug("dialog 'Delete Logical Switch Group' successfully closed") return True else: msg = "failed to wait for dialog 'Delete Logical Switch Group' to close" return FusionUIBase.fail_test_or_return_false(msg, fail_if_false=fail_if_false)
def verify_scope_not_existed(cls, name, wait_timeout=5, fail_if_false=True): logger.debug("verify Scope '%s' not existed ..." % name) return ui_lib.wait_for_element_notvisible( GeneralScopesElements.ID_TABLE_SCOPE_NAME % name, wait_timeout, fail_if_false)
def verify_sht_not_exist(cls, hardware_type, timeout=10, fail_if_false=True): logger.debug("verify [ Server hardware type '%s' ] is not existing" % hardware_type) locator = GeneralServerHardwareTypeElements.ID_TABLE_SHT % hardware_type ui_lib.scroll_into_view(locator) if ui_lib.wait_for_element_notvisible(locator, timeout, fail_if_false): return True else: logger.warn("failed to wait for server hardware type '%s' to be invisible within %s second(s)" % (hardware_type, timeout)) return False
def verify_storage_pool_not_exist(cls, storage_pool, storage_system_name, timeout=5, fail_if_false=True): ''' Verify Storage Pool does not exist ''' logger.debug("verify storage system '%s' is not existing" % storage_pool) if ui_lib.wait_for_element_notvisible(GeneralStoragePoolElements.ID_TABLE_STORAGE_POOL % (storage_pool, storage_system_name), timeout, fail_if_false): return True else: return False
def verify_alert_filter_is_deleted(cls, alert, timeout=5, fail_if_false=True): logger.debug( "Verify that alert filter is deleted and is not listed in Notification page" ) return ui_lib.wait_for_element_notvisible( DeleteAlerFiltertElements.ID_TABLE_ALERT_NAME % alert, timeout, fail_if_false)
def wait_edit_storage_pool_dialog_close(cls, timeout=10, fail_if_false=True): ''' wait for the edity storage pool dialog to close ''' logger.debug("wait for [ Edit Storage Pool ] dialog to get closed") if ui_lib.wait_for_element_notvisible(cls.e.ID_DIALOG_EDIT_STORAGE_POOL, timeout, fail_if_false): logger.debug("successfully closed [ Add Storage Pool ] dialog") return True else: msg = "[ Add Storage Pool ] did NOT get closed" return FusionUIBase.fail_test_or_return_false(msg, fail_if_false=fail_if_false)
def verify_logical_switch_group_should_not_exist(cls, lsg_name, timeout=5, fail_if_false=True): logger.debug("verify Logical Switch Group '%s' should NOT exist ..." % lsg_name) if ui_lib.wait_for_element_notvisible(cls.e.ID_TABLE_LOGICAL_SWITCH_GROUP % lsg_name, timeout=timeout, fail_if_false=fail_if_false): logger.debug("Logical Switch Group '%s' is successfully verified as invisible within %s second(s)" % (lsg_name, timeout)) return True elif ui_lib.wait_for_element_visible(cls.e.ID_TABLE_LOGICAL_SWITCH_GROUP_NOT_FOUND % lsg_name, timeout=timeout, fail_if_false=fail_if_false): logger.debug("Logical Switch Group '%s' was deleted but not de-selected." % lsg_name) return True else: msg = "Logical Switch Group '%s' is failed to be verified as invisible within %s second(s)" % (lsg_name, timeout) return FusionUIBase.fail_test_or_return_false(message=msg, fail_if_false=fail_if_false)
def verify_san_manager_not_exist(cls, san_manager, timeout=5, fail_if_false=True): logger.debug("verify san manager '%s' is not existing" % san_manager) if ui_lib.wait_for_element_notvisible( GeneralSANMangersElements.ID_TABLE_SAN_MANAGER % san_manager, timeout, fail_if_false): return True else: return False
def delete_dashboard(*dashboard_obj): """ Delete Dashboard """ selenium2lib = ui_lib.get_s2l() if not selenium2lib._is_element_present(FusionDashboardPage.ID_PAGE_LABEL): navigate() if type(dashboard_obj) is test_data.DataObj: dashboard_obj = [dashboard_obj] elif type(dashboard_obj) is tuple: dashboard_obj = list(dashboard_obj[0]) for dashboard in dashboard_obj: if len(dashboard.title.strip()) > 0: logger._log_to_console_and_log_file( "\nVerifying Dashboard %s exist..." % dashboard.title) ui_lib.wait_for_element_visible( FusionDashboardPage.ID_LINK_ADD_DASHBOARD) if selenium2lib._is_visible( FusionDashboardPage.ID_LINK_DASHBOARD_NAME % dashboard.title): logger._log_to_console_and_log_file( "Dashboard exist, Deleting Dashboard %s..." % dashboard.title) ui_lib.move_to_element_and_click( FusionDashboardPage.ID_LINK_DASHBOARD_NAME % dashboard.title, FusionDashboardPage.ID_LINK_DASHBOARD_DELETE % dashboard.title) ui_lib.wait_for_element_and_click( FusionDashboardPage.ID_BTN_DASHBOARD_DELETE_CONFIRM) ui_lib.wait_for_element_notvisible( FusionDashboardPage.ID_LINK_DASHBOARD_NAME % dashboard.title) logger._log_to_console_and_log_file("Dashboard %s deleted" % dashboard.title) return True else: message = "Dashboard -- %s is not available or not visible in the Dashboards Page" % dashboard.title raise AssertionError(message) else: message = "\n%s has Dashboard title name is empty" % dashboard.name raise AssertionError(message)
def click_edit_scope_button(cls, timeout=5, fail_if_false=True): logger.debug("Click [ Edit ] button on enclosure scope page") if ui_lib.wait_for_element(EditScopeElements.ID_BUTTON_EDIT, timeout=timeout, fail_if_false=fail_if_false) \ and ui_lib.wait_for_element_visible(EditScopeElements.ID_HEADER_SCOPE, timeout=timeout, fail_if_false=fail_if_false)\ and ui_lib.wait_for_element_notvisible(EditScopeElements.ID_TEXT_SCOPE_NOT_LOAD, timeout=timeout, fail_if_false=fail_if_false): ui_lib.find_element_and_move(EditScopeElements.ID_HEADER_SCOPE) ui_lib.wait_for_element_visible(EditScopeElements.ID_BUTTON_EDIT, timeout=timeout, fail_if_false=fail_if_false) ui_lib.wait_for_element_and_click(EditScopeElements.ID_BUTTON_EDIT, timeout=timeout, fail_if_false=fail_if_false)
def wait_for_element_not_visible(self, locator, timeout=5, fail_if_false=False): """Wait for an element to become non-visible in the given time. Returns true if the element is not visible else returns false. Examples: | Wait For Element Not Visible | hp-login-username | """ return ui_lib.wait_for_element_notvisible(locator, timeout, fail_if_false=fail_if_false)
def check_if_alert_name_exists_for_alert_filter(cls, timeout=5, fail_if_false=True): logger.debug("Validate if the alert name already exist") ui_lib.wait_for_element_and_click( ChooseAlertCriteriaElements.ID_RADIO_ALERT_CRITERIA_PREDEFINED, timeout, fail_if_false) if ui_lib.wait_for_element_notvisible( CreateAlertFilterElements.ID_TEXT_ALERT_EXISTING_NAME, timeout, fail_if_false): return True else: logger.warn("Alert name already exist please use a new name") return False
def verify_volumeset_not_exist(cls, volumeset, storage_system_name, timeout=5, fail_if_false=True): """ On the Volume Sets Page, verify that a specific volumeset does not exist """ logger.debug("verify volumeset '%s' does not exist" % volumeset) if ui_lib.wait_for_element_notvisible( GeneralVolumeSetElements.ID_TABLE_VOLUMESET % (volumeset, storage_system_name), timeout, fail_if_false): return True else: return False
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 restart(): """ Restart Restarts the given fusion appliance Example: | `Restart` | | """ if not ui_lib.wait_for_element(FusionSettingsPage.ID_PAGE_LABEL): navigate() logger._log_to_console_and_log_file("Restart 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_RESTART) if ui_lib.wait_for_element_visible(FusionSettingsPage.ID_LABEL_RESTART): ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_YES_CONFIRM_SHUTDOWN) else: ui_lib.fail_test('Failed: The message while restarting the appliance is not displayed') # Checking whether the fusion appliance started restarting 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 restarted successfully and getting shutdown") else: ui_lib.fail_test('Failed: The fusion appliance failed to restart') # 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') # Checking whether the fusion appliance started to power on or not if ui_lib.wait_for_element_visible(FusionSettingsPage.ID_LABEL_STARTING, PerfConstants.STARTING_PROGRESS_VISIBLE): logger._log_to_console_and_log_file("The fusion appliance is powering on") else: ui_lib.fail_test('Failed: The fusion appliance failed to power on after it is shutdown') # Checking whether the fusion appliance started to coming up if ui_lib.wait_for_element_visible(FusionSettingsPage.ID_LABEL_PROGRESS, PerfConstants.STARTING_PROGRESS_VISIBLE): logger._log_to_console_and_log_file("The fusion appliance is powered on successfully and waiting for the appliance") else: ui_lib.fail_test('Failed: The fusion appliance dint get powered on successfully and appliance couldnot start') # Checking whether the fusion appliance home page if ui_lib.wait_for_element_notvisible(FusionSettingsPage.ID_LABEL_PROGRESS, PerfConstants.STARTING_PROGRESS_VISIBLE): if ui_lib.wait_for_element_visible(FusionDashboardPage.ID_PAGE_LABEL, PerfConstants.FUSION_LOGIN_TIME): logger._log_to_console_and_log_file("The fusion appliance is restarted successfully") else: ui_lib.fail_test('Failed: The fusion appliance did not come up after restart')
def wait_form_message_disappear(cls, timeout=5, fail_if_false=False): logger.debug("wait form message disappear") return ui_lib.wait_for_element_notvisible(AddFirmwareBundleElements.ID_TEXT_FORM_MESSAGE, timeout=timeout, fail_if_false=fail_if_false)
def wait_add_firmware_bundle_dialog_close(cls, timeout=5, fail_if_false=True): logger.debug("wait add firmware bundle dialog close") return ui_lib.wait_for_element_notvisible(AddFirmwareBundleElements.ID_DIALOG_ADD, timeout=timeout, fail_if_false=fail_if_false)
def wait_firmware_bundle_removed(cls, sppname, firmwareversion, timeout=10, fail_if_false=True): logger.debug("wait firmware bundle remove completly") return ui_lib.wait_for_element_notvisible(RemoveFirmwareBundleElements.ID_TITLE_FIRMWARE_BUNDLE % (sppname, firmwareversion), timeout=timeout, fail_if_false=fail_if_false)
def wait_remove_firmware_bundle_dialog_close(cls, timeout=10, fail_if_false=True): logger.debug("wait remove firmware bundle dialog close") return ui_lib.wait_for_element_notvisible(RemoveFirmwareBundleElements.ID_DIALOG_REMOVE, timeout=timeout, fail_if_false=fail_if_false)