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_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")