def userdata_validation(*user_obj): """ Verify User data The function validates the user data in the users and groups page. Example: | `userdata validation` | | """ # retrieving data from data file if isinstance(user_obj, test_data.DataObj): user_obj = [user_obj] elif isinstance(user_obj, tuple): user_obj = list(user_obj) navigate() for user in user_obj: if user.name.lower() == "administrator" or user.has_property( 'domainName'): continue VerifyUser.verify_user_exist(user.name) 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 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