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 __is_racks_table_empty(): logger._log_to_console_and_log_file( "\tVerifying if Racks table is empty or not...") if ui_lib.is_visible( systemprofilesPage.ID_TABLE_EDIT_SYSTEM_PROFILE_RACKS): logger._log_to_console_and_log_file("\t...Table not empty.") return False else: logger._log_to_console_and_log_file("\t...Table is empty.") return True
def open_guided_setup_panel(): """ display the guided setup panel """ if not logged_in(): raise AssertionError("Not logged in") # if the panel is already visible, do nothing if not 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_visible( FusionUIBaseElements.ID_GUIDED_SETUP_PANEL, 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 get_scopename_validate_message(cls, timeout=5, fail_if_false=True, hidden_element=False): logger.debug("Get scopename validate mesaage") if ui_lib.is_visible(GeneralScopesElements.ID_SCOPE_NAME_VALIDATE_MSG, timeout, fail_if_false): return ui_lib.get_text( GeneralScopesElements.ID_SCOPE_NAME_VALIDATE_MSG, timeout, fail_if_false, hidden_element) else: return None
def load_bulk_enets(cls, timeout=5, fail_if_false=True): """ This function will select 1500 bulk enets from a dropdown by scrolling and clicking on load more until all the networks are selected at a single stretch from scopes page for resource assignment. """ selenium2lib = ui_lib.get_s2l() while ui_lib.is_visible(GeneralScopesElements.ID_MOUSE_OVER, timeout, fail_if_false): selenium2lib.mouse_over(GeneralScopesElements.ID_MOUSE_OVER) ui_lib.wait_for_element_and_click( GeneralScopesElements.ID_MOUSE_OVER, timeout, fail_if_false) if ui_lib.wait_for_element_and_click( GeneralScopesElements.ID_TABLE_ENETS_LIST, timeout, fail_if_false): ActionChains(selenium2lib._current_browser()).key_down( Keys.CONTROL).send_keys('a').key_up(Keys.CONTROL).perform() return True
def verify_filter_by_all_scope(cls, xpath_id, name, timeout=5, fail_if_false=True): logger.debug("select scope %s" % name) if not ui_lib.wait_for_element_and_click( VerifyScopesElements.ID_SCOPE_TABLE % xpath_id, timeout, fail_if_false): return ui_lib.fail_test("Failed to select Scope") if not ui_lib.wait_for_element_and_click( VerifyScopesElements.ID_FILTER_BY_TABLE_ITEM % (xpath_id, name), timeout, fail_if_false): return ui_lib.fail_test("Failed to select scope") if ui_lib.is_visible(VerifyScopesElements.ID_ALL_RESOURCE, timeout, fail_if_false): ui_lib.wait_for_element_and_click( VerifyScopesElements.ID_ALL_RESOURCE, timeout, fail_if_false) ui_lib.wait_for_element_and_click( VerifyScopesElements.ID_PAGE_SELECT % xpath_id, timeout, fail_if_false) return True
def set_edit_san_automate_zoning(zone_value): xpath_automate = FusionSANPage.ID_SAN_EDIT_AUTOMATE_ZONING_BTN BuiltIn().sleep(5) automate_zoning = ui_lib.is_visible(FusionSANPage.ID_SAN_EDIT_YES_MESSAGE, 12) logger._log_to_console_and_log_file( "Set Edit SAN Automate Zoning value=%s" % zone_value) BuiltIn().sleep(5) if (zone_value == 'off' and automate_zoning): try: ui_lib.wait_for_element_and_click(xpath_automate, 12) except: return False elif (zone_value == 'on' and automate_zoning): return True elif (zone_value == 'off' and automate_zoning is False): return True elif (zone_value == 'on' and automate_zoning is False): try: ui_lib.wait_for_element_and_click(xpath_automate, 12) except: return False
def is_panel_power_active(cls, timeout=5): logger.debug("check [ Power ] panel active") return ui_lib.is_visible(CreateEnclosureGroupElements.ID_TBIRD_PANEL_POWER_IS_ACTIVE, timeout, fail_if_false=False)
def is_edit_enclosure_group_dialog_open(cls, timeout=5): logger.debug("check if [ Edit Enclosure Group dialog ] is open") if not ui_lib.is_visible(EditEnclosureGroupElements.ID_DIALOG_EDIT_ENCLOSURE_GROUP, timeout, fail_if_false=False): return False return True
def is_panel_lig_active(cls, timeout=5): logger.debug("check [ Interconnect bay configuration ] panel active") return ui_lib.is_visible(CreateEnclosureGroupElements.ID_PANEL_LIG_IS_ACTIVE, timeout, fail_if_false=False)
def is_panel_general_active(cls, timeout=5): logger.debug("check [ General ] panel active") return ui_lib.is_visible(CreateEnclosureGroupElements.ID_PANEL_GENERAL_IS_ACTIVE, timeout, fail_if_false=False)
def is_panel_selector_active(cls, timeout=5): logger.debug("check [ Panel Selector(General/View) ] is active") return ui_lib.is_visible(CreateEnclosureGroupElements.ID_PANEL_SELECTOR_IS_ACTIVE, timeout, fail_if_false=False)
def wait_disable_to_visible(cls, timeout=5): logger.debug("wait and check if disable is there") return ui_lib.is_visible( NotificationElements.ID_TOGGLE_NOTIFICATION_ENABLE_ALTER_EMAIL, timeout, fail_if_false=True)
def wait_enable_visible_alert_page(cls, timeout=5): logger.debug("wait if enable is displayed") return ui_lib.is_visible( NotificationElements.ID_TOGGLE_ALERT_EMAIL_FILTER, timeout, fail_if_false=True)
def get_latest_activity(cls, wait_timeout=5, fail_if_false=True): logger.debug("GETTING THE LATEST MSG IN ACTIVITY PAGE") ui_lib.is_visible(FusionActivityPage.ID_LATEST_ACTIVITY_LABEL, wait_timeout, fail_if_false) return ui_lib.get_text(FusionActivityPage.ID_LATEST_ACTIVITY_LABEL, wait_timeout, fail_if_false)
def is_panel_configscript_active(cls, timeout=5): logger.debug("check [ Configuration script ] panel active") return ui_lib.is_visible(CreateEnclosureGroupElements.ID_PANEL_CONFIGSCRIPT_IS_ACTIVE, timeout, fail_if_false=False)