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 get_alert_criteria_displayed(cls, timeout=5): logger.debug("get the displayed alert criteria") return ui_lib.get_webelement_attribute( "value", EditAlertFilterElements.ID_TEXT_ALERT_CRITERIA, timeout, fail_if_false=True)
def get_email_address(cls, timeout=5): logger.debug("get the previous email address") return ui_lib.get_webelement_attribute( "value", EditAlertFilterElements.ID_INPUT_EDIT_ALERT_EMAIL_ADDRESS, timeout, fail_if_false=True)
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 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 verify_advanced_radio_selected_by_default(cls, timeout=5, fail_if_false=True): logger.debug( "Verify that advanced criteria is selected by default in edit alert filter page" ) return ui_lib.get_webelement_attribute( "checked", EditAlertFilterElements.ID_RADIO_ALERT_FILTER_ADVANCED, timeout, fail_if_false)
def verify_sanmanager_managedsans_count_link(): logger._log_to_console_and_log_file( "Function call to validate managedsanscount link from Sanmanager") 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: """ skip hp direct attach san manager - can not be deleted """ if ((san_mangr.__contains__("OneView") or san_mangr.__contains__("Direct")) is False): 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) xpath_section = FusionSANManagersPage.ID_LINK_SANSCOUNT try: ui_lib.wait_for_element_visible(xpath_section, 5) except: pass ui_lib.wait_for_element_and_click(xpath_section) san_page_title = FusionSANPage.ID_SAN_HEADING_TOP try: ui_lib.wait_for_element_visible(san_page_title, 5) except: pass title = "SANs" if ((ui_lib.get_text(san_page_title, 1)) == title): logger._log_to_console_and_log_file("Navigated to" + title + "Page") else: ui_lib.fail_test("unable to navigate to" + title + "page") if not s2l._is_element_present( FusionSANManagersPage.ID_PAGE_LABEL): if not navigate(): return False else: """ add to count so that len of list and count are equal """ logger._log_to_console_and_log_file( "Flat san could not be validated") return True
def _list_networks_vlan(): """ This function is to list the networks in appliance with the corresponding VLAN ID Example: _list_networks_vlan() """ s2l = ui_lib.get_s2l() """ Navigate to Network Page """ if not ui_lib.wait_for_element(FusionNetworksPage.ID_PAGE_LABEL): navigate() ui_lib.wait_for_element(FusionNetworksPage.ID_NETWORK_LIST) networkdict = {} network_list = [ ui_lib.get_webelement_attribute("text", el) for el in s2l._element_find(FusionNetworksPage.ID_NETWORK_LIST_NAMES, False, False) ] for netobj in network_list: vlan = s2l._get_text(FusionNetworksPage.ID_NETWORK_VLAN % str(netobj)) networkdict[netobj] = vlan return networkdict
def page_navigated(self): xpath_main_menu = FusionUIBaseElements.ID_MAIN_MENU_CONTROL xpath_page_label = FusionSANManagersPage.ID_PAGE_LINK # xpath_details_title = FusionSANManagersPage.DETAILS_TITLE try: style = ui_lib.get_webelement_attribute(locator=xpath_main_menu, attribute='style') if 'width' not in style: logger._info('Clicking Main Menu [%s]' % xpath_main_menu) ui_lib.wait_for_element_and_click(xpath_main_menu) logger._info('Waiting for link [SAN Managers] shown') ui_lib.wait_for_element_visible(xpath_page_label, 5) logger._info('Clicking [SAN Managers] [%s]' % xpath_page_label) ui_lib.wait_for_element_and_click(xpath_page_label) logger._info('Waiting for page label [SAN Managers] shown') except: return False return True
def add_vcenter(*vcen_obj): """ add_vCenter function to add vCenter to the appliance Example: | `Add vCenter` | @{vcen_obj} | """ s2l = ui_lib.get_s2l() if not ui_lib.wait_for_element(FusionvCenterPage.ID_PAGE_LABEL): navigate() if isinstance(vcen_obj, test_data.DataObj): vcen_obj = [vcen_obj] elif isinstance(vcen_obj, tuple): vcen_obj = list(vcen_obj[0]) # variable to hold the no of vCenters count = 0 vcenterpools = [] vcenterpool_list = [ ui_lib.get_webelement_attribute("text", s) for s in s2l._element_find( FusionvCenterPage.ID_VCENTER_LIST_NAMES, False, False) ] for pool in vcen_obj: logger._log_to_console_and_log_file( "Verifying vCenters if already exists...") if pool in vcenterpool_list: logger._warn("vcenter'{0}' already exists".format(pool.name)) else: vcenterpools.append(pool) if len(vcenterpools) == 0: logger._warn( "All vcenters passed from data sheet are already existing..") return True else: logger._log_to_console_and_log_file( "vcenters are in a list to be added") """ Loop to add vCenter """ for vcenter in vcenterpools: logger._log_to_console_and_log_file("Adding vcenter: '%s'" % vcenter.name) if s2l._is_element_present(FusionvCenterPage.ID_VCENTER_BUTTON): ui_lib.wait_for_element_and_click( FusionvCenterPage.ID_VCENTER_BUTTON) # Check whether mandatory fields are empty or not if (vcenter.hostname == "" or vcenter.username == "" or vcenter.password == ""): logger._warn( "Mandatory fields for adding vcenter can't be empty") continue else: logger._log_to_console_and_log_file( "Typing vcenter ip address..") ui_lib.wait_for_element_and_input_text( FusionvCenterPage.ID_INPUT_VCENTER_IP_ADDRESS, vcenter.hostname) logger._log_to_console_and_log_file("Typing user name..") ui_lib.wait_for_element_and_input_text( FusionvCenterPage.ID_INPUT_USERNAME, vcenter.username) logger._log_to_console_and_log_file("Typing password..") ui_lib.wait_for_element_and_input_text( FusionvCenterPage.ID_INPUT_PASSWORD, vcenter.password) ui_lib.wait_for_element_and_click( FusionvCenterPage.ID_BTN_VCENTER_ADD) # if add vCenter fails,below script will capture the error msg and display to console if (ui_lib.wait_for_element( FusionvCenterPage.ID_ADD_VCENTER_ERR_MSG, PerfConstants.DEFAULT_SYNC_TIME * 2)): logger._warn("Unable to add vcenter: '%s'" % vcenter.name) msgText2 = ui_lib.get_text( FusionvCenterPage.ID_ADD_VCENTER_ERR_DETAILS) logger._warn(msgText2) continue # verifying vCenter is added and displayed in UI ui_lib.wait_for_element(FusionvCenterPage.ID_VCENTER_LIST, PerfConstants.DEFAULT_SYNC_TIME * 2) s2l.wait_until_page_contains_element( FusionvCenterPage.ID_ELEMENT_VCENTER % vcenter.name, PerfConstants.ADD_VCENTER_TIME) logger._log_to_console_and_log_file( "vcenter %s is added Successfully and it is available in vCenter List" % vcenter.name) # validating vCenter is added or not logger._log_to_console_and_log_file("Validating vCenter %s" % vcenter.name) logger._log_to_console_and_log_file("Clicking on Activity button") ui_lib.wait_for_element_and_click( FusionvCenterPage.ID_ACTIVITY_VCENTER) if ui_lib.wait_for_element(FusionvCenterPage.ID_ELEMENT_ACTIVITY % vcenter.name): if ui_lib.wait_for_element( FusionvCenterPage.ID_ACTIVITY_ADD_STATUS_OK % vcenter.name, PerfConstants.DEFAULT_SYNC_TIME * 2): logger._log_to_console_and_log_file( "vCenter %s added successfully" % vcenter.name) count = count + 1 elif ui_lib.wait_for_element( FusionvCenterPage.ID_ACTIVITY_STATUS_WARNING, PerfConstants.DEFAULT_SYNC_TIME * 2): logger._warn("vCenter %s is added with warning" % vcenter.name) else: logger._warn("Failed to add vcenter %s" % vcenter.name) ui_lib.wait_for_element_and_click( FusionvCenterPage.ID_ACTIVITY_VCENTER) else: logger._warn("Failed to open add vcenter page") """ once all the vCenters are added , matching the count with the vCenters length """ if len(vcenterpools) == count: logger._log_to_console_and_log_file( "SUCCESS : Added all the vCenters to the Fusion Appliance") return True else: logger._warn( "FAILURE : Not able to add all vCenters as mentioned in the data file. " ) return False
def get_advanced_criteria_displayed(cls, timeout=5): logger.debug("get the list of advanced criteria displayed") return ui_lib.get_webelement_attribute( "value", ChooseAlertCriteriaElements.ID_TEXT_ALERT_FILTER_ADVANCED_ALERTS, timeout)
def verify_sanmanager_managedsan_link(): logger._log_to_console_and_log_file( "Function call to validate managedsan link from Sanmanager") 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: """ skip hp direct attach san manager - can not be processed """ if ((san_mangr.__contains__("OneView") or san_mangr.__contains__("Direct")) is False): 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) xpath_section = FusionSANManagersPage.ID_MANAGEDSAN_LIST sans_number = ui_lib.get_text( FusionSANManagersPage.ID_LINK_SANSCOUNT, 1) sans_count = sans_number.replace("SANs", "") sans_count = int(sans_count) try: ui_lib.wait_for_element_visible(xpath_section, 5) except: pass for san in range(sans_count): xpath_san = build_xpath_managed_sans_table(str(san + 1)) try: ui_lib.wait_for_element_visible(xpath_san, 5) except: pass san_value_sanmanagerpage = ui_lib.get_text(xpath_san, 1) ui_lib.wait_for_element_and_click(xpath_san) xpath_sanvalue_sanpage = FusionSANPage.ID_SAN_DETAILS_TITLE try: ui_lib.wait_for_element_visible(xpath_sanvalue_sanpage, 5) except: pass san_value_sanspage = ui_lib.get_text(xpath_sanvalue_sanpage, 1) if (san_value_sanmanagerpage == san_value_sanspage): logger._log_to_console_and_log_file( san_value_sanmanagerpage + " link and value verified ") else: ui_lib.fail_test("unable to navigate to" + san_value_sanspage + "page and verify") if not s2l._is_element_present( FusionSANManagersPage.ID_PAGE_LABEL): if not navigate(): return False else: """ add to count so that len of list and count are equal """ logger._log_to_console_and_log_file( "Flat san could not be validated") return True
def edit_unmanaged_device(*uds_obj): """ Edit 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 edit_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 edit_uds.name not in uds_list: ui_lib.fail_test("Unmanaged device '%s' not exists. Cannot proceed with editing" % edit_uds.name) selenium2lib.capture_page_screenshot() failed_times = failed_times + 1 continue logger._log_to_console_and_log_file("Editing Unmanaged device %s" % edit_uds.name) logger._log_to_console_and_log_file("-----------------------------") ui_lib.wait_for_element_and_click(FusionUnmanagedDevicePage.ID_ELEMENT_UNAMANGED_DEVICE_BASE % edit_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_EDIT) if edit_uds.has_property("new_name"): ui_lib.wait_for_element_and_input_text(FusionUnmanagedDevicePage.ID_INPUT_NAME_UNMANAGED_DEVICE, edit_uds.new_name) if edit_uds.has_property("model"): ui_lib.wait_for_element_and_input_text(FusionUnmanagedDevicePage.ID_INPUT_MODEL, edit_uds.model) if edit_uds.has_property("height"): # for i in range(1,42): # selenium2lib.press_key(FusionUnmanagedDevicePage.ID_COMBO_HEIGHT, '\\38') # while selenium2lib.get_text(FusionUnmanagedDevicePage.ID_COMBO_HEIGHT) != edit_uds.height: # selenium2lib.press_key(FusionUnmanagedDevicePage.ID_COMBO_HEIGHT, '\\40') ui_lib.wait_for_element_and_click(FusionUnmanagedDevicePage.ID_COMBO_HEIGHT) ui_lib.wait_for_element_and_click(FusionUnmanagedDevicePage.ID_COMBO_OPTION % edit_uds.height) if edit_uds.has_property("maxpower"): ui_lib.wait_for_element_and_input_text(FusionUnmanagedDevicePage.ID_INPUT_MAXIMUM_POWER, edit_uds.maxpower) # ui_lib.wait_for_element_visible(FusionUnmanagedDevicePage.ID_INPUT_MODEL) selenium2lib.click_button(FusionUnmanagedDevicePage.ID_BTN_UPDATE) logger._log_to_console_and_log_file("Checking for Edit status of Unmanaged device %s " % edit_uds.name) # ui_lib.wait_for_element_visible(FusionUnmanagedDevicePage.ID_UDS_UPDATE_SUCESS, PerfConstants.UPDATE_UNMANGED_DEVICE_TIME) ui_lib.wait_for_element_visible(FusionUnmanagedDevicePage.ID_UDS_UPDATE_SUCESS, PerfConstants.UPDATE_UNMANGED_DEVICE_TIME) if ui_lib.wait_for_element(FusionUnmanagedDevicePage.ID_UDS_UPDATE_SUCESS): logger._log_to_console_and_log_file("Unmanaged device '%s' is updated successfully" % edit_uds.name) else: selenium2lib.capture_page_screenshot() failed_times = failed_times + 1 ui_lib.fail_test("Editing Unmanaged device '%s' is Failed" % edit_uds.name) if failed_times > 0: return False else: return True
def add_unmanaged_device(*uds_obj): """ Add 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 in uds_list: logger._warn("Unmanaged device '%s' already exists. Cannot proceed with adding Unmanaged device" % uds.name) selenium2lib.capture_page_screenshot() failed_times = failed_times + 1 continue if(uds.name == "" or uds.model == "" or uds.maxpower == ""): logger._warn("Mandatory fields for adding Unmanaged device can't be empty") selenium2lib.capture_page_screenshot() failed_times = failed_times + 1 continue logger._log_to_console_and_log_file("Adding Unmanaged device %s" % uds.name) logger._log_to_console_and_log_file("-----------------------------") ui_lib.wait_for_element_and_click(FusionUnmanagedDevicePage.ID_LINK_CREATE_UD) ui_lib.wait_for_element_visible(FusionUnmanagedDevicePage.ID_INPUT_NAME_UNMANAGED_DEVICE) ui_lib.wait_for_element_and_input_text(FusionUnmanagedDevicePage.ID_INPUT_NAME_UNMANAGED_DEVICE, uds.name) ui_lib.wait_for_element_visible(FusionUnmanagedDevicePage.ID_INPUT_MODEL) ui_lib.wait_for_element_and_input_text(FusionUnmanagedDevicePage.ID_INPUT_MODEL, uds.model) ui_lib.wait_for_element_visible(FusionUnmanagedDevicePage.ID_COMBO_HEIGHT) # ui_lib.wait_for_element_and_click(FusionUnmanagedDevicePage.ID_COMBO_HEIGHT) # for i in range(1, 42): # selenium2lib.press_key(FusionUnmanagedDevicePage.ID_COMBO_HEIGHT, '\\38') # while selenium2lib.get_text(FusionUnmanagedDevicePage.ID_COMBO_HEIGHT) != uds.height: # selenium2lib.press_key(FusionUnmanagedDevicePage.ID_COMBO_HEIGHT, '\\40') ui_lib.wait_for_element_and_click(FusionUnmanagedDevicePage.ID_COMBO_HEIGHT) ui_lib.wait_for_element_and_click(FusionUnmanagedDevicePage.ID_COMBO_OPTION % uds.height) ui_lib.wait_for_element_visible(FusionUnmanagedDevicePage.ID_INPUT_MAXIMUM_POWER) ui_lib.wait_for_element_and_input_text(FusionUnmanagedDevicePage.ID_INPUT_MAXIMUM_POWER, uds.maxpower) ui_lib.wait_for_element_visible(FusionUnmanagedDevicePage.ID_BTN_ADD_UNMANAGED_DEVICE) selenium2lib.click_button(FusionUnmanagedDevicePage.ID_BTN_ADD_UNMANAGED_DEVICE) logger._log_to_console_and_log_file("Checking whether Unmanaged device %s is added or not" % uds.name) selenium2lib.wait_until_page_contains_element(FusionUnmanagedDevicePage.ID_LINK_CREATE_UD) if ui_lib.wait_for_element(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 in uds_list: logger._log_to_console_and_log_file("Unmanaged device '%s' is added successfully" % uds.name) if failed_times > 0: return False else: return True