def test_update_info_illegal_param(self): time.sleep(1) info_btn = NaviTest.driver.find_element_by_css_selector( "#navbar > ul > li:nth-child(2) > a") assert info_btn is not None info_btn.click() update_btn = NaviTest.driver.find_element_by_css_selector( "#navbar > ul > li.dropdown.open > ul > li:nth-child(1) > a") assert update_btn is not None update_btn.click() fullname_input = NaviTest.driver.find_element_by_id("fullName") email_input = NaviTest.driver.find_element_by_id("email") phone = NaviTest.driver.find_element_by_id("phone") assert fullname_input is not None assert email_input is not None assert phone is not None fullname_input.send_keys(USER_INFO["fullname"]) email_input.send_keys("illegal") phone.send_keys(USER_INFO["phone"]) submit_btn = NaviTest.driver.find_element_by_id( "submit-profile-form-btn") assert submit_btn is not None submit_btn.click() setup.success_btn_click(NaviTest.driver) print("[test_update_info_illegal_param] test done")
def test_pass_modify_incorrect_pass(self): time.sleep(1) info_btn = NaviTest.driver.find_element_by_css_selector( "#navbar > ul > li:nth-child(2) > a") assert info_btn is not None info_btn.click() modify_btn = NaviTest.driver.find_element_by_css_selector( "#navbar > ul > li.dropdown.open > ul > li:nth-child(2) > a") assert modify_btn is not None modify_btn.click() old_pass_input = NaviTest.driver.find_element_by_id("oldPassword") new_pass_input = NaviTest.driver.find_element_by_id("newPassword") retype_pass_input = NaviTest.driver.find_element_by_id( "retypePassword") submit_btn = NaviTest.driver.find_element_by_id("change-passwd-submit") assert not (old_pass_input is None or new_pass_input is None or retype_pass_input is None or submit_btn is None) old_pass_input.send_keys("incorrect") new_pass_input.send_keys("123456") retype_pass_input.send_keys("123456") submit_btn.click() setup.success_btn_click(NaviTest.driver) print("[test_pass_modify_incorrect_pass] test done")
def test_switch_users(self): setup.admin_user_btn_click(UserStateTest.driver) items = UserStateTest.get_user_items() for i in range(2): checkbox = items[i].find_element_by_css_selector("td:nth-child(1) > input") if not checkbox: continue checkbox.click() state_btn = UserStateTest.driver.find_element_by_id("switch-state-btn") assert state_btn is not None state_btn.click() btns = setup.get_confirm_box_btns(UserStateTest.driver) btns[1].click() setup.success_btn_click(UserStateTest.driver) print("[test_switch_users] test done.")
def test_pass_modify_no_param(self): time.sleep(1) info_btn = NaviTest.driver.find_element_by_css_selector( "#navbar > ul > li:nth-child(2) > a") assert info_btn is not None info_btn.click() modify_btn = NaviTest.driver.find_element_by_css_selector( "#navbar > ul > li.dropdown.open > ul > li:nth-child(2) > a") assert modify_btn is not None modify_btn.click() submit_btn = NaviTest.driver.find_element_by_id("change-passwd-submit") assert submit_btn is not None submit_btn.click() setup.success_btn_click(NaviTest.driver) print("[test_pass_modify_incorrect_pass] test done")
def test_update_info_no_param(self): time.sleep(1) info_btn = NaviTest.driver.find_element_by_css_selector( "#navbar > ul > li:nth-child(2) > a") assert info_btn is not None info_btn.click() update_btn = NaviTest.driver.find_element_by_css_selector( "#navbar > ul > li.dropdown.open > ul > li:nth-child(1) > a") assert update_btn is not None update_btn.click() submit_btn = NaviTest.driver.find_element_by_id( "submit-profile-form-btn") assert submit_btn is not None submit_btn.click() setup.success_btn_click(NaviTest.driver) print("[test_update_info_no_param] test done")
def test_reset_one_user(self): setup.admin_user_btn_click(PassResetTest.driver) items = PassResetTest.get_user_items() assert len(items) > 0 checkbox = items[0].find_element_by_css_selector( "td:nth-child(1) > input") assert checkbox is not None checkbox.click() reset_btn = PassResetTest.driver.find_element_by_id( "reset-password-btn") assert reset_btn is not None reset_btn.click() btns = setup.get_confirm_box_btns(PassResetTest.driver) btns[1].click() setup.success_btn_click(PassResetTest.driver) print("[test_reset_one_user] test done.")
def test_activate_user(self): setup.admin_user_btn_click(UserStateTest.driver) items = UserStateTest.get_user_items() for item in items: state = item.find_element_by_css_selector("td:nth-child(7) > span").text if state == "已禁用": checkbox = item.find_element_by_css_selector("td:nth-child(1) > input") if checkbox is None: continue checkbox.click() break state_btn = UserStateTest.driver.find_element_by_id("switch-state-btn") assert state_btn is not None state_btn.click() btns = setup.get_confirm_box_btns(UserStateTest.driver) btns[1].click() setup.success_btn_click(UserStateTest.driver) print("test_deactivate_user test done")
def test_activate_admin(self): setup.admin_user_btn_click(AdminStateTest.driver) items = AdminStateTest.get_user_items() for item in items: state = item.find_element_by_css_selector( "td:nth-child(8) > span").text if state == "普通用户": checkbox = item.find_element_by_css_selector( "td:nth-child(1) > input") if checkbox is None: continue checkbox.click() break admin_btn = AdminStateTest.driver.find_element_by_id( "switch-admin-btn") assert admin_btn is not None admin_btn.click() btns = setup.get_confirm_box_btns(AdminStateTest.driver) btns[1].click() setup.success_btn_click(AdminStateTest.driver) print("[test_activate_admin] test done")