class Test_AddUser_t: # def setup_class(self): # ''' # 非調試端口用 # ''' # self.main = Main().goto_login(). \ # username(self.setup_datas["username).password(self.setup_datas["password).save(). \ # goto_application(). \ # goto_classtimetable(self.setup_datas["application) # # def teardown_class(self): # ''' # 非調試端口啓用 # ''' # self.main.close() def setup(self): ''' 開啓調試端口啓用 ''' self.main = Main() def teardown(self): ''' 開啓調試端口啓用 ''' self.main = Main().close_adduser_pop() @pytest.mark.parametrize("name,enname,staffno," "username_t," "port_id,email,group,tel," "groupSortOrder,expect", test_create_data()) def test_add_user(self, name, enname, staffno, username_t, port_id, email, group, tel, groupSortOrder, expect): ''' 驗證添加教職工 ''' result = self.main.goto_unified_data().goto_user().\ goto_teacher().goto_add_user_t().click_add().name(name).\ enname(enname).staffno(staffno).username(username_t).\ port(port_id).email(email).group(group).tel(tel).\ groupSortOrder(groupSortOrder).submit().get_adduser_succeed() assert result == expect
class Test_Search_Student: _do_excel = Do_Excel(username_dir, 'user_s') _cases = _do_excel.read_excel() _setup_datas = get_env() _working = _get_working() if _working == "port": def setup(self): ''' 開啓調試端口啓用 ''' self.main = Main() def teardown(self): ''' 開啓調試端口啓用 ''' try: self.main.close_drawer() except Exception as e: pass else: def setup_class(self): ''' 非調試端口用 ''' self.main = Main().goto_login(). \ username(self._setup_datas["username"]).password(self._setup_datas["password"]).save() def teardown(self): try: self.main.close_drawer() except Exception as e: pass def teardown_class(self): ''' 非調試端口啓用 ''' self.main.close() @pytest.mark.parametrize("data", _cases) def test_search_student_username(self, data): ''' 查找學生數量,驗證賬號存在 ''' result = self.main.goto_unified_data(). \ goto_user().goto_student(). \ search_user_s(data.username).\ get_the_fir_row_text(data.username) assert True == result @pytest.mark.parametrize("data", _cases) def test_get_staffNo_for_search_username(self, data): ''' 查找學生賬號,返回學生學號 ''' try: result = self.main.goto_unified_data(). \ goto_user().goto_student(). \ search_user_s(data.username).get_the_first_staffNo(data.username) db = shelve.open("staffNo_s") self._do_excel.write_excel(data.id + 1, 3,db["staffNo_s"]) db.close() assert True == result except AssertionError as e: self._do_excel.write_excel(data.id + 1, 3,'None') raise e
class Test_Edit_User_T: with open(test_edit_user_t_dir, encoding="utf-8") as f: datas = yaml.safe_load(f) test_edit_post_user_t_datas = datas["test_edit_post_user_t"] test_edit_post_name_user_t_datas = datas["test_edit_post_name_user_t"] test_edit_leave_type_user_t_datas = datas["test_edit_leave_type_user_t"] test_edit_leave_info_user_t_datas = datas["test_edit_leave_info_user_t"] test_edit_password_user_t_datas = datas["test_edit_password_user_t"] test_edit_email_t_datas = datas["test_edit_email_t"] test_get_email_t_datas = datas["test_get_email_t"] test_get_post_t_datas = datas["test_get_post_t"] _setup_datas = get_env() _working = _get_working() if _working == "port": def setup(self): ''' 開啓調試端口啓用 ''' self.main = Main() def teardown(self): ''' 開啓調試端口啓用 ''' try: self.main.close_drawer() except Exception as e: pass else: def setup_class(self): ''' 非調試端口用 ''' self.main = Main().goto_login(). \ username(self._setup_datas["username"]).password(self._setup_datas["password"]).save() def teardown(self): ''' 關閉抽屜 :return: ''' try: self.main.close_drawer() except Exception as e: pass def teardown_class(self): ''' 非調試端口啓用 ''' self.main.close() @pytest.mark.parametrize("data", test_edit_post_user_t_datas) def test_edit_post_user_t(self, data): ''' DC设置岗位,注意uat更改崗位前要等待>=9s,dev等待1s,传参是岗位id ''' result = self.main.goto_unified_data().\ goto_user().goto_teacher().\ search_user_t(data["user_t"]).\ edit_the_first_user_t(data["user_t"]).wait_sleep(9).\ edit_post(data["post_id"],data["post"]).\ click_save().get_the_first_user_t_post(data["user_t"]) assert data["post"] in result @pytest.mark.parametrize("data", test_edit_post_name_user_t_datas) def test_edit_post_name_user_t(self, data): ''' DC设置岗位,注意uat更改崗位前要等待>=9s,dev等待1s,传参是岗位名称 ''' result = self.main.goto_unified_data().\ goto_user().goto_teacher().\ search_user_t(data["user_t"]).\ edit_the_first_user_t(data["user_t"]).wait_sleep(10).\ edit_post_name(data["post_name"]).\ click_save().get_the_first_user_t_post(data["user_t"]) for post in data["post_name"]: assert post not in result @pytest.mark.parametrize("data", test_edit_leave_type_user_t_datas) def test_edit_leave_type_user_t(self, data): ''' DC设置休假类型 ''' result = self.main.goto_unified_data(). \ goto_user().goto_teacher(). \ search_user_t(data["user_t"]). \ edit_the_first_user_t(data["user_t"]). \ edit_leave_type(data["leave_type"]).\ click_save().get_the_first_user_t_post(data["user_t"]) assert data["expect"] in result @pytest.mark.parametrize("data", test_edit_leave_info_user_t_datas) def test_edit_leave_info_user_t(self, data): ''' DC设置岗位、入职日期,合同期 ''' result = self.main.goto_unified_data(). \ goto_user().goto_teacher(). \ search_user_t(data["user_t"]). \ edit_the_first_user_t(data["user_t"]). \ edit_post(data["post_id"], data["post"]). \ edit_date_of_entry(data["entrydate"]).\ edit_contract_start_date(data["contract_start_date"]).\ edit_contract_end_date(data["contract_end_date"]).\ click_save().get_the_first_user_t_post(data["user_t"]) assert data["expect"] in result @pytest.mark.parametrize("data", test_edit_password_user_t_datas) def test_edit_password_user_t(self, data): ''' DC修改登錄密碼,uat打開編輯頁面等待元素出現需要>8s ''' result = self.main.goto_unified_data(). \ goto_user().goto_teacher(). \ search_user_t(data["user_t"]). \ edit_the_first_user_t(data["user_t"]). \ wait_sleep(10).edit_password(self._setup_datas["password"]). \ click_save().get_the_first_user_t_user(data["user_t"]) assert data["expect"] == result @pytest.mark.parametrize("data", test_edit_email_t_datas) def test_edit_email_t(self, data): ''' DC修改系统邮箱 ''' result = self.main.goto_unified_data(). \ goto_user().goto_teacher(). \ search_user_t(data["user_t"]). \ edit_the_first_user_t(data["user_t"]). \ edit_email(data["email"]).\ click_save().get_the_first_user_t_user(data["user_t"]) assert data["user_t"] in result @pytest.mark.parametrize("data", test_get_email_t_datas) def test_get_email_t(self, data): ''' DC获取系统邮箱 注意:uat打開抽屜定位到元素需要等待5s以上,若在獲取郵箱前等待,則獲取郵箱后無需等待 ''' result = self.main.goto_unified_data(). \ goto_user().goto_teacher(). \ search_user_t(data["user_t"]). \ view_the_first_user_t(data["user_t"]). \ wait_sleep(8).get_email(). \ close_page().get_the_first_user_t_user(data["user_t"]) assert data["user_t"] in result @pytest.mark.parametrize("data", test_get_post_t_datas) def test_get_post_t(self, data): ''' DC獲取人員崗位 ''' result = self.main.goto_unified_data(). \ goto_user().goto_teacher(). \ search_user_t(data["user_t"]). \ get_the_first_user_t_post(data["user_t"]) assert data["expect"] in result
class Test_Edit_User_S: with open(test_edit_user_s_dir, encoding="utf-8") as f: datas = yaml.safe_load(f) test_edit_password_user_s_datas = datas["test_edit_password_user_s"] test_edit_other_msg_s_datas = datas["test_edit_other_msg_s"] test_search_student_username_datas = datas[ "test_search_student_username"] test_edit_post_and_faculy_datas = datas["test_edit_post_and_faculy"] test_edit_user_and_staffNo_datas = datas["test_edit_user_and_staffNo"] test_edit_user_datas = datas["test_edit_user"] _setup_datas = get_env() _working = _get_working() if _working == "port": def setup(self): ''' 開啓調試端口啓用 ''' self.main = Main() def teardown(self): ''' 開啓調試端口啓用 ''' try: self.main.close_drawer() except Exception as e: pass else: def setup_class(self): ''' 非調試端口用 ''' self.main = Main().goto_login(). \ username(self._setup_datas["username"]).password(self._setup_datas["password"]).save() def teardown(self): ''' 判斷,若抽屜沒關閉,則先關閉抽屜在進行下一個用例,否則會導致後續用例失敗 :return: ''' try: self.main.close_drawer() except Exception as e: pass def teardown_class(self): ''' 非調試端口啓用 ''' self.main.close() @pytest.mark.parametrize("data", test_edit_password_user_s_datas) def test_edit_password_user_s(self, data): ''' DC修改登錄密碼 ''' result = self.main.goto_unified_data(). \ goto_user().goto_student(). \ search_user_s(data["user_s"]). \ edit_she_first_user_s(data["user_s"]). \ edit_password(self._setup_datas["password"]).\ edit_sortOrder(data["sortorder"]).\ click_save().get_add_ele() assert data["expect"] == result @pytest.mark.parametrize("data", test_edit_post_and_faculy_datas) def test_edit_post_and_faculy(self, data): ''' DC修改崗位和學院 ''' result = self.main.goto_unified_data(). \ goto_user().goto_student(). \ search_user_s(data["user_s"]). \ edit_she_first_user_s(data["user_s"]).edit_post_s(data["post_id"]).\ edit_faculy(data["faculy_id"]).click_save().get_add_ele() assert data["expect"] == result @pytest.mark.parametrize("data", test_search_student_username_datas) def test_search_student_username(self, data): ''' 查找學生數量,驗證賬號存在 ''' result = self.main.goto_unified_data(). \ goto_user().goto_student(). \ search_user_s(data["user_s"]). \ get_the_first_staffNo(data["user_s"]) assert data["user_s"] == result @pytest.mark.parametrize("data", test_edit_user_and_staffNo_datas) def test_edit_user_and_staffNo(self, data): ''' DC修改賬號和學號 ''' result = self.main.goto_unified_data(). \ goto_user().goto_student(). \ search_user_s(data["user_s"]). \ edit_she_first_user_s(data["user_s"]).edit_post_s(data["post_id"]). \ edit_faculy(data["faculy_id"]).edit_name(data["name"]).edit_enname(data["enname"]). \ edit_user(data["user"]).edit_password(data["psd"]).edit_sortOrder(data["sortOrder"]). \ edit_staffNo(data["staffNo"]).edit_type_of_accommodation(). \ edit_program(data["program"]).edit_programCode(data["programCode"]).\ edit_entrance_term(data["entrance_term"]).edit_entrance_date(data["entrance_date"]).\ click_save().get_not_data_text(data["user"]) return result == data["expect"] @pytest.mark.parametrize("data", test_edit_user_datas) def test_edit_user(self, data): ''' DC修改 ''' result = self.main.goto_unified_data(). \ goto_user().goto_student(). \ search_user_s(data["user_s"]). \ edit_she_first_user_s(data["user_s"]).edit_post_s(data["post_id"]). \ edit_faculy(data["faculy_id"]).edit_password(data["psd"]).edit_sortOrder(data["sortOrder"]). \ edit_type_of_accommodation(). \ edit_program(data["program"]).edit_programCode(data["programCode"]).\ edit_entrance_term(data["entrance_term"]).edit_entrance_date(data["entrance_date"]).\ click_save().get_the_first_username(data["user_s"]) return result == data["expect"]
class Test_Search_Teacher: _do_excel = Do_Excel(username_dir, 'user_t') _cases = _do_excel.read_excel() _setup_datas = get_env() _working = _get_working() if _working == "port": def setup(self): ''' 開啓調試端口啓用 ''' self.main = Main() def teardown(self): ''' 開啓調試端口啓用 ''' try: self.main.close_drawer() except Exception as e: pass else: def setup_class(self): ''' 非調試端口用 ''' self.main = Main().goto_login(). \ username(self._setup_datas["username"]).password(self._setup_datas["password"]).save() def teardown(self): try: self.main.close_drawer() except Exception as e: pass def teardown_class(self): ''' 非調試端口啓用 ''' self.main.close() @pytest.mark.parametrize("data", _cases) def test_search_teacher_username(self, data): ''' 查找老師數量,驗證賬號存在 ''' result = self.main.goto_unified_data(). \ goto_user().goto_teacher(). \ search_user_t(data.username).\ get_the_fir_row_text(data.username) assert True == result @pytest.mark.parametrize("data", _cases) def test_get_post_for_search_username(self, data): ''' 查找老師賬號,返回老師崗位 ''' try: result = self.main.goto_unified_data(). \ goto_user().goto_teacher(). \ search_user_t(data.username).get_the_first_user_t_post(data.username) db = shelve.open("post_t") self._do_excel.write_excel(data.id + 1, 3, db["post_t"]) db.close() assert "崗位" in result except AssertionError as e: self._do_excel.write_excel(data.id + 1, 3, 'None') raise e @pytest.mark.parametrize("data", _cases) def test_get_emali_for_search_username(self, data): ''' 查找老師賬號,返回老師崗位 注意:uat打開抽屜定位到元素需要等待5s以上,若在獲取郵箱前等待,則獲取郵箱后無需等待 ''' try: result = self.main.goto_unified_data(). \ goto_user().goto_teacher(). \ search_user_t(data.username).view_the_first_user_t(data.username).\ wait_sleep(5).get_email().close_page().get_the_first_user_t_user(data.username) db = shelve.open("email_t") self._do_excel.write_excel(data.id + 1, 4, db["email_t"]) db.close() assert data.username in result except AssertionError as e: self._do_excel.write_excel(data.id + 1, 4, 'None') raise e