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 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 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 choose_synchronize_with_time_server(cls, timeout=5, fail_if_false=True): logger.debug("choose Synchronize with time server") ui_lib.wait_for_element_and_click( EditTimeAndLocaleElements.ID_RADIO_SYNCHRONIZE_WITH_TIME_SERVER, timeout, fail_if_false)
def validate_general_section_titles(): xpath_section = FusionSANManagersPage.ID_MENU_VIEW_MAIN_BTN xpath_title1 = FusionSANManagersPage.ID_VIEW_GENERAL_SAN_MANAGER xpath_title3 = FusionSANManagersPage.ID_VIEW_ACTIVITY_SAN_MANAGER xpath_title4 = FusionSANManagersPage.ID_VIEW_MAP_SAN_MANAGER try: ui_lib.wait_for_element_visible(xpath_section, 5) except: pass ui_lib.wait_for_element_and_click(xpath_section) title = "General" if ((ui_lib.get_text(xpath_title1, 1)) == title): logger._log_to_console_and_log_file(title + "Section found") else: ui_lib.fail_test("unable to find the" + title + "section") title = "Activity" if ((ui_lib.get_text(xpath_title3, 1)) == title): logger._log_to_console_and_log_file(title + "Section found") else: ui_lib.fail_test("unable to find the" + title + "section") title = "Map" if ((ui_lib.get_text(xpath_title4, 1)) == title): logger._log_to_console_and_log_file(title + "Section found") else: ui_lib.fail_test("unable to find the" + title + "section") return True
def click_remove_resources_button_from_scope(cls, wait_timeout=5, fail_if_false=True): logger.debug("click remove resources button") ui_lib.wait_for_element_and_click( EditScopesElements.ID_BUTTON_REMOVE_RESOURCE_FROM_SCOPE, wait_timeout, fail_if_false)
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 click_predefined_from_list(cls, timeout=5): logger.debug("select predefined alert from list") ui_lib.wait_for_element_and_click( ChooseAlertCriteriaElements. ID_BUTTON_ALERT_FILTER_PRE_ALERTS_SCROLL, timeout, fail_if_false=True)
def select_actions_refresh(cls, timeout=5): ''' On the Storage Pool Page, select action menu refresh ''' logger.debug("select refresh") ui_lib.wait_for_element_and_click(GeneralStoragePoolElements.ID_BUTTON_ACTIONS, timeout, fail_if_false=True) ui_lib.wait_for_element_and_click(RefreshStoragePoolElements.ID_SELECT_ACTION_REFRESH, timeout, fail_if_false=True)
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 select_action_edit(cls, timeout=5, fail_if_false=True): ''' On the Storage Pool Page, click on action menu button ''' logger.debug("select action 'Edit'") ui_lib.wait_for_element_and_click(GeneralStoragePoolElements.ID_BUTTON_ACTIONS, timeout=timeout, fail_if_false=fail_if_false) ui_lib.wait_for_element_and_click(cls.e.ID_SELECT_ACTION_EDIT, timeout=timeout, fail_if_false=fail_if_false)
def _verify_activity_owner(actname, resource, timestamp, assignusername): """ This function is to verify the user name once the activity is assigned to any user. This function is written wrt E2E UC3.it will work only when we pass all the four parameters. Example: _verify_activity_owner('Update started for interconnect CC-2-LI', 'CC-2-LI', 'Today 10.45 am', 'NetAdmin') """ selenium2lib = ui_lib.get_s2l() if not selenium2lib._is_element_present(FusionActivityPage.ID_PAGE_LABEL): selenium2lib.click_element(FusionUIBaseElements.ID_MAIN_MENU_CONTROL) ui_lib.wait_for_element_visible( FusionUIBaseElements.ID_MENU_LINK_ACTIVITY, PerfConstants.DEFAULT_SYNC_TIME) ui_lib.wait_for_element_and_click( FusionUIBaseElements.ID_MENU_LINK_ACTIVITY) ui_lib.wait_for_element_visible(FusionActivityPage.ID_PAGE_LABEL) actavailable = _is_element_present_activity_page_without_time( actname, resource) if actavailable: assignuser_name = selenium2lib.get_text( FusionActivityPage.ID_ASSIGNED_OWNER % (actname, resource, timestamp)) if assignuser_name == assignusername: logger._log_to_console_and_log_file( "Activity is available with assigned user name only") else: logger._warn( "Activity is not available with assigned user name") else: logger._warn("Assigned activity is not visible to this user %s" % assignusername)
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 validate_all_states_filter(): xpath_states = FusionSANPage.ID_SAN_ALL_STATES logger._log_to_console_and_log_file( "Validate All States Filter on the SAN Page %s") try: ui_lib.wait_for_element_visible(xpath_states, 10) except: pass ui_lib.wait_for_element_and_click(xpath_states) if (ui_lib.get_text(FusionSANPage.ID_SAN_ALL_STATES_DISCOVERED, 1) == "Discovered"): logger._log_to_console_and_log_file("State Discovered found") else: ui_lib.fail_test( "unable to find the Discovered State, the value is" + ui_lib.get_text(FusionSANPage.ID_SAN_ALL_STATES_DISCOVERED, 1)) if (ui_lib.get_text(FusionSANPage.ID_SAN_ALL_STATES_MANAGED, 1) == "Managed"): logger._log_to_console_and_log_file("Status Managed found") else: ui_lib.fail_test( "unable to find the Managed State, the value is" + ui_lib.get_text(FusionSANPage.ID_SAN_ALL_STATES_MANAGED, 1))
def add_user_input_filter(filter_name, values): logger._log_to_console_and_log_file( "Adding data to %s filter on san endpoints" % filter_name) selenium2lib = ui_lib.get_s2l() selenium2lib.maximize_browser_window() if (filter_name == 'endpoint'): xpath_filter = FusionSANPage.ID_SAN_ENDPOINTS_FILTER_ENDPOINT elif (filter_name == 'wwpn'): xpath_filter = FusionSANPage.ID_SAN_ENDPOINTS_FILTER_WWPN elif (filter_name == 'alias'): xpath_filter = FusionSANPage.ID_SAN_ENDPOINTS_FILTER_ALIAS elif (filter_name == 'online'): xpath_filter = FusionSANPage.ID_SAN_ENDPOINTS_FILTER_ONLINE elif (filter_name == 'zone'): xpath_filter = FusionSANPage.ID_SAN_ENDPOINTS_FILTER_ZONE else: logger._log_to_console_and_log_file( "Invalid action requested for san endpoints filter") return False try: ui_lib.wait_for_element_visible(xpath_filter, 20) except: pass ui_lib.wait_for_element_and_click(xpath_filter, 20) ui_lib.wait_for_element_and_input_text(xpath_filter, values)
def validate_tab_required(): logger._log_to_console_and_log_file( "Function call to validate tabs on SAN managers") s2l = ui_lib.get_s2l() """ Navigate to SAN Manager Page """ if not s2l._is_element_present(FusionSANManagersPage.ID_PAGE_LABEL): if not navigate(): return False san_mangr_list = [ ui_lib.get_webelement_attribute("text", el) for el in s2l._element_find( FusionSANManagersPage.ID_SAN_MANAGER_LIST_NAMES, False, False) ] for san_mangr in san_mangr_list: logger._log_to_console_and_log_file("validating san manager %s" % san_mangr) ui_lib.wait_for_element_and_click( FusionSANManagersPage.ID_ELEMENT_SAN_MANAGER % san_mangr) if ((san_mangr.__contains__("OneView") or san_mangr.__contains__("Direct")) is False): '''validate_general_section_titles()''' logger._log_to_console_and_log_file("san manager= %s" % san_mangr) validate_general_section_titles() sanmanager_actions_validate() else: logger._log_to_console_and_log_file( "Flat san found as san manager") sanmanager_actions_flatsan_validate() return True
def open_san_action(action_name): xpath_action = FusionSANPage.ID_SAN_MENU_ACTION_MAIN_BTN logger._log_to_console_and_log_file("Choose %s from action menu" % action_name) if (action_name == 'Edit'): xpath_action2 = FusionSANPage.ID_SAN_MENU_ACTION_EDIT elif (action_name == 'Refresh'): xpath_action2 = FusionSANPage.ID_SAN_MENU_ACTION_REFRESH elif (action_name == 'Download'): xpath_action2 = FusionSANPage.ID_SAN_MENU_ACTION_DOWNLOAD elif (action_name == 'Report'): xpath_action2 = FusionSANPage.ID_SAN_MENU_ACTION_REPORT else: logger._log_to_console_and_log_file("Invalid action requested on san") return False try: ui_lib.wait_for_element_visible(xpath_action, 10) except: pass logger._log_to_console_and_log_file("Open SAN actions menu-%s" % action_name) ui_lib.wait_for_element_and_click(xpath_action, 10) ui_lib.wait_for_element_and_click(xpath_action2, 10)
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 san_endpoints_click_update(): xpath_update = FusionSANPage.ID_SAN_ENDPOINTS_UPDATE try: ui_lib.wait_for_element_visible(xpath_update, 10) except: pass ui_lib.wait_for_element_and_click(xpath_update)
def edit_san_click_ok(): xpath_edit = FusionSANPage.ID_SAN_EDIT_OK_BUTTON try: ui_lib.wait_for_element_visible(xpath_edit, 10) except: pass ui_lib.wait_for_element_and_click(xpath_edit)
def highlight_san(san_value): xpath_input = (FusionSANPage.ID_SAN_LIST + "[text()='%s']" % san_value) try: ui_lib.wait_for_element_visible(xpath_input, 5) except: pass logger._log_to_console_and_log_file("Highlighting san=%s" % san_value) ui_lib.wait_for_element_and_click(xpath_input)
def edit_san_manager_click_cancel(): xpath_cancel = FusionSANManagersPage.ID_BTN_EDIT_SAN_MANAGER_CANCEL try: ui_lib.wait_for_element_visible(xpath_cancel, 10) except: pass ui_lib.wait_for_element_and_click(xpath_cancel)
def input_select_logical_interconnect_group(cls, bay, logical_interconnect_group, timeout=5): logger.debug("- About to choose LIG %s for bay %s" % (logical_interconnect_group, bay)) BuiltIn().sleep(3) ui_lib.wait_for_element_and_input_text(EditEnclosureGroupElements.ID_INPUT_C7000_CHOOSE_LIG % bay, "", timeout, fail_if_false=True) BuiltIn().sleep(3) ui_lib.wait_for_element_and_input_text(EditEnclosureGroupElements.ID_INPUT_C7000_CHOOSE_LIG % bay, logical_interconnect_group, timeout, fail_if_false=True) BuiltIn().sleep(3) ui_lib.wait_for_element_and_click(EditEnclosureGroupElements.ID_COMBO_C7000_OPTION_LIG % (bay, logical_interconnect_group), timeout, fail_if_false=True)
def select_lig(cls, enc_no, switch_no, switch_lig, timeout=5, fail_if_false=True): logger.debug("select %s for lig" % switch_lig) # select the existing LIG from dropdown.If not present raise warning if ui_lib.wait_for_element_visible(CreateEnclosureGroupElements.ID_TBIRD_SELECT_OPTION_CHOOSE_LIG % (enc_no, switch_no, switch_lig), timeout, fail_if_false): ui_lib.wait_for_element_and_click(CreateEnclosureGroupElements.ID_TBIRD_SELECT_OPTION_CHOOSE_LIG % (enc_no, switch_no, switch_lig), timeout, fail_if_false=False, js_click=True) return True else: return False
def endpoints_click_download(): xpath_download = FusionSANPage.ID_SAN_DOWNLOAD_ENDPOINTS try: ui_lib.wait_for_element_visible(xpath_download, 10) except: pass ui_lib.wait_for_element_and_click(xpath_download)
def edit_san_manager_click_ok(): xpath_ok = FusionSANManagersPage.ID_BTN_EDIT_SAN_MANAGER_OK try: ui_lib.wait_for_element_visible(xpath_ok, 10) except: pass ui_lib.wait_for_element_and_click(xpath_ok)
def add_san_manager_click_add_plus(): xpath_add_plus = FusionSANManagersPage.ID_BTN_SAN_MANAGER_ADD_PLUS try: ui_lib.wait_for_element_visible(xpath_add_plus, 10) except: pass ui_lib.wait_for_element_and_click(xpath_add_plus)
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 add_datacenter(*datacenter_obj): ''' add_datacenter function to add data center into appliance ''' ''' QXCR1001317088 Racks layout is not resetting after clicking on ADD+ button in Data center page. In DataCenter page when we click on Add data center button by giving valid input , adding racks to the data center clicking on ADD+ button it is added , All the fields are getting reset except the racks and rack layout what we have added in previous data center, and when we are going to add one more data center by giving valid input ,adding racks to the data center we are not able to add data center. ''' logging._log_to_console_and_log_file("Adding Data center to the appliance") selenium2lib = ui_lib.get_s2l() navigate() flag = None if isinstance(datacenter_obj, test_data.DataObj): datacenter_obj = [datacenter_obj] elif isinstance(datacenter_obj, tuple): datacenter_obj = list(datacenter_obj[0]) # Go into adding the data center fail = 0 for datacenters in datacenter_obj: # Function to call _add_datacenter_property flag = _add_datacenter_property(datacenters) add_rack = None if datacenters.has_property('addrack'): add_rack = datacenters.addrack if add_rack is None: logging._log_to_console_and_log_file( "There is no new rack to be added") if isinstance(add_rack, (list)): for rack in add_rack: _add_rack_to_datacenter(rack) if flag: ui_lib.wait_for_element_and_click( FusionDataCenterPage.ID_BTN_ADD_DATACENTER) ui_lib.wait_for_element_visible( FusionDataCenterPage.ID_LINK_ADD_DATA_CENTER) if selenium2lib._is_element_present( FusionDataCenterPage.ID_LINK_ADD_DATA_CENTER): logging._log_to_console_and_log_file( "Data center is successfully added") else: logging._warn("Data Center is not added") selenium2lib.capture_page_screenshot() fail += 1 else: ui_lib.wait_for_element_and_click( FusionDataCenterPage.ID_BTN_CANCEL_PLUS_DATACENTER) logging._warn("Data center is not added") selenium2lib.capture_page_screenshot() fail += 1 if fail > 0: return False return True
def click_volumes_link(cls, timeout=5): """ On the Volume Sets Page, click the volumes link """ logger.debug("Click used by volumes link on volume sets screen") ui_lib.wait_for_element_and_click( GeneralVolumeSetElements.ID_LINK_USED_BY_VOLUMES, timeout, fail_if_false=True)