def get_fc_networks_from_test_data(self): """ return a list of all fibre channel network objects Examples: |${fc_networks} = | Get FC Networks From Test Data | """ return test_data.get().fcnetworks
def get_users_from_test_data(self): """ return a list of all of the user objects Examples: |${users} = | Get Users From Test Data | """ return test_data.get().users
def get_ethernet_networks_from_test_data(self): """ return a list of all ethernet network objects Examples: | ${networks} = | Get Ethernet Networks From Test Data | """ return test_data.get().networks
def get_usernames_from_test_data(self): """ return a list of all usernames Examples: | ${names} = | Get Usernames From Test Data | """ return [user.name for user in test_data.get().users]
def get_user_from_test_data(self, user_name): """ return the user object based on the name provided Examples: | Get User From Test Data | Administrator | """ user = [ user for user in test_data.get().users if user.name == user_name ] if len(user) == 0: return None else: return user[0]
def _first_time_login(password): logger._log_to_console_and_log_file("Login to Fusion..") env_data = test_data.get().envconfigs env_data = env_data[0] selenium2lib = ui_lib.get_s2l() if not ui_lib._get_browser_status(): ui_lib.open_browser() if selenium2lib._is_element_present(FusionLoginPage.ID_BTN_EULA_AGREE): selenium2lib.click_button(FusionLoginPage.ID_BTN_EULA_AGREE) selenium2lib.wait_until_page_contains_element( FusionLoginPage.ID_BTN_LOGIN_BUTTON) selenium2lib.input_text(FusionLoginPage.ID_INPUT_LOGIN_USER, env_data.appliance_username) selenium2lib.input_text(FusionLoginPage.ID_INPUT_LOGIN_PASSWORD, password) selenium2lib.click_button(FusionLoginPage.ID_BTN_LOGIN_BUTTON) if not ui_lib.wait_for_element_visible( FusionLoginPage.ID_INPUT_NEW_PASSWORD, 4): selenium2lib.wait_until_page_contains("Dashboard", 10, "Failed to load the Login Page") FusionUIBase.set_login_status(True)
def edit_current_session_user(user_obj): """ Edit Current Session User This functions allows you to edit current session user whoever users listed in user page retrieving data from data.xml """ logger.info("Edit Current Session User...") user = test_data.get().currentSessionUser user = user[0] if isinstance(user_obj, test_data.DataObj): user_obj = [user_obj] elif isinstance(user_obj, tuple): user_obj = list(user_obj) # Login with current session user credentials EditCurrentSessionUser.input_login_user_name(user.name) EditCurrentSessionUser.input_login_password(user.password) EditCurrentSessionUser.click_login_button() if EditCurrentSessionUser.wait_login_dashboard_shown(30, False): logger.info("Login Successful") else: logger.warn( "Login Fail. Invalid username or password. Enter correct credentials and try again." ) return False EditCurrentSessionUser.click_current_session_user_edit_button() EditCurrentSessionUser.wait_edit_user_dialog_shown() # Edit full name if user.has_property('fullname'): EditCurrentSessionUser.input_full_name(user.fullname) # Enter current password if user.has_property('password'): EditCurrentSessionUser.input_current_password(user.password) # Enter New password if user.has_property('newpassword'): EditCurrentSessionUser.input_new_password(user.newpassword) EditCurrentSessionUser.input_confirm_password(user.newpassword) # Enter confirm password if user.has_property('confirmpassword'): EditCurrentSessionUser.input_confirm_password(user.confirmpassword) # Edit email if user.has_property('email'): EditCurrentSessionUser.input_email(user.email) # Edit office phone number if user.has_property('officephone'): EditCurrentSessionUser.input_office_phone(user.officephone) # Edit Mobile number if user.has_property('mobilephone'): EditCurrentSessionUser.input_mobile_phone(user.mobilephone) # Confirm Edit - Clicking OK EditCurrentSessionUser.click_ok_button() EditCurrentSessionUser.wait_edit_user_dialog_disappear() # Logging out logger.info("LOGOUT") EditCurrentSessionUser.click_logout_button() # Login with Current User if password has changed if user.has_property('newpassword'): logger.info("Login with new password") EditCurrentSessionUser.input_login_user_name(user.name) EditCurrentSessionUser.input_login_password(user.newpassword) EditCurrentSessionUser.click_login_button() if EditCurrentSessionUser.wait_login_dashboard_shown(30, False): logger.info("Changed Password of '%s' is verified Successfully" % user.name) # Logging out logger.info("LOGOUT") EditCurrentSessionUser.click_logout_button() else: logger.warn("Password verification of '%s' failed" % user.name) # Login with Administrator and verify edit logger.info("Login with Administrator") EditCurrentSessionUser.input_login_user_name(user.adminuser) EditCurrentSessionUser.input_login_password(user.adminpassword) EditCurrentSessionUser.click_login_button() if EditCurrentSessionUser.wait_login_dashboard_shown(30, False): logger.info("Administrator successfully logged in") else: logger.warn( "Login Fail. Invalid username or password. Enter correct credentials and try again." ) return False navigate() GeneralUserandGroups.click_user(user.name) VerifyUser.verify_user_title(user.name) VerifyUser.verify_user_login_name(user.name) if user.has_property("fullname"): VerifyUser.verify_user_full_name(user.fullname) if user.has_property("email"): VerifyUser.verify_user_email(user.email) if user.has_property("officephone"): VerifyUser.verify_user_office_phone(user.officephone) if user.has_property("mobilephone"): VerifyUser.verify_user_mobile_phone(user.mobilephone) return True
def fusion_configure_first_time_wizard(): """ fusion_configure_first_time_wizard """ logger._log_to_console_and_log_file( "Configuring fusion first time wizard..") env_data = test_data.get().envconfigs env_data = env_data[0] ftw_data = test_data.get().ftwizard ftw_data = ftw_data[0] ftw_data_ipv4 = ftw_data.ipv4[0] ftw_data_ipv6 = ftw_data.ipv6[0] selenium2lib = ui_lib.get_s2l() default_wait = PerfConstants.DEFAULT_SYNC_TIME """ Accepting EULA page """ if ui_lib.wait_for_element_visible(FusionLoginPage.ID_BTN_EULA_AGREE, default_wait): selenium2lib.click_button(FusionLoginPage.ID_BTN_EULA_AGREE) if ui_lib.wait_for_element_visible( FusionLoginPage.ID_BTN_OK_CONVERGED_INFRA_SUPPORT, default_wait): if ftw_data.hp_support_access.upper() == "DISABLE": selenium2lib.click_element( FusionLoginPage.ID_TOGGLE_HP_SUPPORT_ACCESS_ENABLE) selenium2lib.click_button( FusionLoginPage.ID_BTN_OK_CONVERGED_INFRA_SUPPORT) """ Login into appliance with default IP address and default credentials """ selenium2lib.wait_until_page_contains_element( FusionLoginPage.ID_INPUT_LOGIN_USER, default_wait, "Failed to load the Login Page") ui_lib._set_browser_status(True) _first_time_login(env_data.appliance_default_password) """ Changing appliance default password """ if (env_data.appliance_password is not None) or (len(env_data.appliance_password) >= 8) or ( env_data.appliance_password == env_data.confirm_password): if ui_lib.wait_for_element_visible( FusionLoginPage.ID_INPUT_NEW_PASSWORD, default_wait): selenium2lib.input_text(FusionLoginPage.ID_INPUT_NEW_PASSWORD, env_data.appliance_password) selenium2lib.input_text(FusionLoginPage.ID_INPUT_CONFIRM_PASSWORD, env_data.appliance_password) selenium2lib.click_button( FusionLoginPage.ID_BTN_OK_PASSWORD_SCREEN) else: logger._warn( "Mandatory fields for changing default password can't be empty and should be at least 8 characters" ) """ Updating Network parameters """ if ui_lib.wait_for_element_visible( FusionLoginPage.ID_INPUT_APPLIANCE_HOSTNAME, default_wait): logger._log_to_console_and_log_file("Configuring Appliance Networking") if ftw_data_ipv4.assignments.upper() == "DHCP": selenium2lib.click_element(FusionLoginPage.ID_RADIO_IPV4_DHCP) elif (ftw_data_ipv4.ipaddress is not None) and (ftw_data_ipv4.subnetmask is not None): selenium2lib.click_element(FusionLoginPage.ID_RADIO_IPV4_MANUAL) selenium2lib.input_text(FusionLoginPage.ID_INPUT_IPV4_IPADDRESS, ftw_data_ipv4.ipaddress) selenium2lib.input_text(FusionLoginPage.ID_INPUT_IPV4_MASK, ftw_data_ipv4.subnetmask) ui_lib.input_text_if_property_exist( FusionLoginPage.ID_INPUT_IPV4_GATEWAY, "gateway", ftw_data_ipv4) else: logger._warn( "Mandatory fields for configuring appliance can't be empty") ui_lib.input_text_if_property_exist( FusionLoginPage.ID_INPUT_PREFFERED_DNS, "preferred_dns", ftw_data) ui_lib.input_text_if_property_exist( FusionLoginPage.ID_INPUT_ALTERNATE_DNS, "alternate_dns", ftw_data) selenium2lib.input_text(FusionLoginPage.ID_INPUT_APPLIANCE_HOSTNAME, ftw_data.appliance_hostname) """ IPv6 """ selenium2lib.click_element(FusionLoginPage.ID_COMBO_MENU_VIEW) selenium2lib.click_element(FusionLoginPage.ID_LINK_DNS) ui_lib.wait_for_element_visible(FusionLoginPage.ID_RADIO_IPV6_MANUAL, 5) if ftw_data_ipv6.assignments.upper() == "MANUAL": selenium2lib.click_element(FusionLoginPage.ID_RADIO_IPV6_MANUAL) selenium2lib.input_text(FusionLoginPage.ID_INPUT_IPV6_IPADDRESS, ftw_data_ipv6.ipaddress) selenium2lib.input_text(FusionLoginPage.ID_INPUT_IPV6_MASK, ftw_data_ipv6.subnetmask) ui_lib.input_text_if_property_exist( FusionLoginPage.ID_INPUT_IPV6_GATEWAY, "gateway", ftw_data_ipv6) elif ftw_data_ipv6.assignments.upper() == "DHCP": selenium2lib.click_element(FusionLoginPage.ID_RADIO_IPV6_DHCP) else: selenium2lib.click_element(FusionLoginPage.ID_RADIO_IPV6_UNASSIGN) selenium2lib.click_button(FusionLoginPage.ID_BTN_OK_NETWORK_ASSIGNMENT) """ Verifying the configured appliance IP address""" apply_network_settings = PerfConstants.CONFIGURE_NETWORK_SETTINGS_FTW if ui_lib.wait_for_element_visible( FusionLoginPage.ID_ELEMENT_ERROR_MESSAGE, default_wait): ui_lib.fail_test( "Error message displayed while configuring the network") else: if ui_lib.wait_for_element_visible( FusionLoginPage.ID_INPUT_LOGIN_USER, apply_network_settings): selenium2lib.input_text(FusionLoginPage.ID_INPUT_LOGIN_USER, env_data.appliance_username) selenium2lib.input_text( FusionLoginPage.ID_INPUT_LOGIN_PASSWORD, env_data.appliance_password) selenium2lib.click_element(FusionLoginPage.ID_BTN_LOGIN_BUTTON) if ui_lib.wait_for_element_visible( FusionDashboardPage.ID_ELEMENT_ENCLOSURE, default_wait): ui_lib.fail_test("Failed to configure the appliance") else: logger._log_to_console_and_log_file( "Appliance Network Configuration is done successfully")