class TestRegister: #初始化,setup方法会在下面每个测试用例前执行 def setup(self): self.main = Main() def test_register(self): #链式调用 main方法中的gotoregister,可以return到Register中的register方法 #assert self.main.goto_register().register() self.main.goto_login().goto_register().register()
class TestLogin: def setup(self): self.main = Main() def teardown(self): pass def test_login(self): self.main.goto_login().do_scan() assert '吕川,开始探索企业微信' in self.main.driver.page_source assert '退出' == self.main.find(By.ID, 'logout').text
class TestContract: def setup(self): self.main = Main() self.main.goto_login().do_scan() self.main.driver.find_element(By.XPATH, "//*[@id='menu_contacts']").click() time.sleep(2) def teardown(self): # 清除数据 pass def test_add_department(self): result = self.main.goto_add_department().add_department( ).get_department_list() assert '和平精英' in result
class TestRegister: def setup(self): self.main = Main() def test_register(self): assert self.main.goto_register().register() def test_login(self): assert self.main.goto_login().goto_register().register()
class TestLogin: _name = "test11" _psd = "123456" def setup_class(self): self.main = Main() def teardown_class(self): self.main.close() def setup(self): self.login = self.main.goto_login().username(self._name).password(self._psd).save() def teardown(self): self.main.quit() @pytest.mark.parametrize("name,psd",[("test12","wemust123"),("test11","123456")]) @pytest.mark.skip def testlogin(self,name,psd): ''' 測試登錄功能 :return: ''' self.main.goto_login().username(name).password(psd).save() def test_selectapplication(self): ''' 測試打開選擇應用的頁面 :return: ''' self.login.goto_application() def test_gotoapplication(self): ''' 測試打開某個應用 :return: ''' application_name = "課表" memu = "教師課表(本科)" self.login.goto_application().\ goto_classtimetable(application_name). \ goto_teacher_management_degree(memu)
class Test0924: with open(test_authorization_dir, encoding="utf-8") as f: datas = yaml.safe_load(f) setup_datas = datas["setup_datas"] test_get_memu_num_datas = datas["test_get_memu_num"] def setup_class(self): ''' 非調試端口用 ''' # self.main = Main().goto_login(). \ # username(self.setup_datas["username"]).password(self.setup_datas["password"]).save(). \ # goto_application(). \ # goto_exam(self.setup_datas["application"]) self.main = Main() def setup(self): ''' 非調試端口用 ''' self.begin=self.main.goto_login(). \ username(self.setup_datas["username"]).password(self.setup_datas["password"]).save(). \ goto_application(). \ goto_exam(self.setup_datas["application"]) def teardown(self): ''' 非調試端口用 ''' self.main.back_to_index().quit() def teardown_class(self): ''' 非調試端口啓用 ''' self.main.close() # def setup(self): # ''' # 開啓調試端口啓用 # ''' # self.main = Main() @pytest.mark.parametrize("data", test_get_memu_num_datas) def test_get_memu_num(self, data): ''' 權限測試,驗證取消排考計劃權限,菜單只有5個 ''' result = self.begin.get_memu_num() assert result == data["expect"]
class TestAuthsNewStuList: name = "test12" pas = "******" application_name = "入學" staffNo = "1102853A-S011-0262" def setup_class(self): self.main = Main() def teardown_class(self): self.main.quit() def setup(self): self.index = self.main.goto_index() def teardown(self): self.index.backto_index() def test_menus_noexist(self): result = self.main.goto_login().\ username(self.name).password(self.pas).save().\ goto_application().\ goto_registration(self.application_name).\ goto_newstulist() assert result == False def test_export(self): result = self.main.goto_login(). \ username(self.name).password(self.pas).save(). \ goto_application(). \ goto_registration(self.application_name).\ goto_newstulist().\ export() assert result == False def test_detail(self): result = self.main.goto_login(). \ username(self.name).password(self.pas).save(). \ goto_application(self.application_name). \ goto_result = self.main.goto_login(). \ username(self.name).password(self.pas).save(). \ goto_application(). \ goto_registration(self.application_name).\ goto_newstulist().goto_detail_nosearch() print(f"打印result:{result}") assert result == "-" def test_student_detail(self): result = self.main.goto_login(). \ username(self.name).password(self.pas).save(). \ goto_application(self.application_name). \ goto_result = self.main.goto_login(). \ username(self.name).password(self.pas).save(). \ goto_application(). \ goto_registration(self.application_name). \ goto_newstulist(). \ simple_search(self.staffNo). \ goto_details(self.staffNo).\ goto_event_detail() assert result == False def test_eventdetail_edit(self): result = self.main.goto_login(). \ username(self.name).password(self.pas).save(). \ goto_application(self.application_name). \ goto_result = self.main.goto_login(). \ username(self.name).password(self.pas).save(). \ goto_application(). \ goto_registration(self.application_name). \ goto_newstulist(). \ simple_search(self.staffNo). \ goto_details(self.staffNo).\ edit_dress() assert result == False