class Organ(unittest.TestCase): datas = read_data_excel('addorgan') departmentname, index_number, departmentdescription, rolename, branch_id, superiorposition_id, roledescription, email, phone, expected = datas[ 0] def setUp(self) -> None: self.driver = chrome() lp = LoginPage(self.driver) lp.login('admin', '123456') def test_organ(self): hp = HomePage(self.driver) hp.head_portrait() sleep(2) hp.organizational_structure_submit() sleep(2) op = OrPage(self.driver) op.add_departmentnamedescription(self.departmentname, self.index_number, self.departmentdescription) sleep(3) op.add_role(self.rolename, self.branch_id, self.superiorposition_id, self.roledescription) sleep(3) op.cheakandalter(self.email, self.phone) self.assertIn(self.expected, op.assert_elment(), msg='编辑失败') def tearDown(self) -> None: self.driver.quit()
class Organization(BaseCase): newpartname, newrolename, expected = read_data_excel('editorgan')[0] def test_organization(self): hp = HomePage(self.driver) hp.head_portrait() sleep(2) hp.organizational_structure_submit() sleep(2) op = OrganizationPage(self.driver) op.origanization_element() sleep(2) op.alterrole(self.newpartname) # 编辑部门 sleep(2) op.moveto_delete() # 删除部门 sleep(2) op.alter_role(self.newrolename) # 编辑岗位 sleep(2) op.roledelete_element() sleep(2) op.searchuser() sleep(2) self.assertEqual(int(self.expected), op.aserttable_element(), msg='测试不通过')
def test_operation_log_case(self): '''登录''' self.driver = chrome() lp = LoginPage(self.driver) username, password = ReadExcel('login') lp.login(username, password) #个人资料-修改个人资料-组织架构-添加架构-添加岗位-操作日志-查询出全部操作日志-删除其中一条操作日志 hp3 = HomePage(self.driver) email, phone, expected = ReadExcel('my_data') hp3.homepage3(email, phone) sleep(2) #组织架构添加岗位 op1 = OrPage(self.driver) rolename, branch_id, superiorposition_id, roledescription = read_data_excel( 'addorgan')[1][3:7] op1.add_role(rolename, branch_id, superiorposition_id, roledescription) #点击头像-操作日志 hp4 = HomePage(self.driver) hp4.homepage4() sleep(2) #查询全部类型的操作日志-删除一个操作日志 olp = OperationLogPage(self.driver) olp.operationlogpage() hp4.alert_submit() sleep(2) #断言 # expected = '成功删除了相关记录' actual = olp.assert_agin() self.assertIn(expected, actual, msg='删除操作日志失败')
class Log(unittest.TestCase): addlogtile, content, newtitle, keyword, expected = read_data_excel('addlog')[0] def setUp(self) -> None: self.driver = chrome() lp = LoginPage(self.driver) lp.login('admin', '123456') def test_log(self): hp = HomePage(self.driver) hp.more_element() sleep(2) hp.log_element() lp = LogPage(self.driver) lp.addlog(self.addlogtile, self.content) # 新建日志 sleep(2) lp.cheak_log() # 查看日志 sleep(2) lp.alter_log(self.newtitle) # 编辑日志 sleep(2) lp.search_log(self.keyword) # 搜索日志 sleep(2) lp.delete_log() # 删除日志 sleep(2) self.assertIn('暂无数据!', lp.assert_delete(self.keyword), msg='删除失败') def tearDown(self) -> None: self.driver.quit()
class KnowledgeCase(BaseCase): kntitle,kncontent,newtitle,knkeyword,expected=read_data_excel('addkno')[0] def test_knowledge(self): hp=HomePage(self.driver) hp.more_element()#点击更多 sleep(1) hp.knowlede_element()#点击知识 kp=KnowledgePage(self.driver)#实例化KnowledgePage kp.addknowledge(self.kntitle,self.kncontent) sleep(4) kp.cheakknowledge(self.newtitle) sleep(2) kp.searchk_element(self.knkeyword) sleep(2) kp.deletekonwledge() sleep(1) self.assertIn(self.expected,kp.assertdlete_knoledge(self.knkeyword),msg='删除失败')
class Organ(BaseCase): datas = read_data_excel('addorgan') departmentname, index_number, departmentdescription, rolename, branch_id, superiorposition_id, roledescription, email, phone, expected = datas[ 0] def test_organ(self): hp = HomePage(self.driver) hp.head_portrait() sleep(2) hp.organizational_structure_submit() sleep(2) op = OrPage(self.driver) op.add_departmentnamedescription(self.departmentname, self.index_number, self.departmentdescription) sleep(3) op.add_role(self.rolename, self.branch_id, self.superiorposition_id, self.roledescription) sleep(3) op.cheakandalter(self.email, self.phone) self.assertIn(self.expected, op.assert_elment(), msg='编辑失败')
class Log(BaseCase): addlogtile, content, newtitle, keyword, expected = read_data_excel( 'addlog')[0] def test_log(self): hp = HomePage(self.driver) hp.more_element() sleep(2) hp.log_element() lp = LogPage(self.driver) lp.addlog(self.addlogtile, self.content) #新建日志 sleep(2) lp.cheak_log() #查看日志 sleep(2) lp.alter_log(self.newtitle) #编辑日志 sleep(2) lp.search_log(self.keyword) #搜索日志 sleep(2) lp.delete_log() #删除日志 sleep(2) self.assertIn('暂无数据!', lp.assert_delete(self.keyword), msg='删除失败')
class Organization(unittest.TestCase): newpartname, newrolename, expected = read_data_excel('editorgan')[0] def setUp(self) -> None: self.driver = chrome() lp = LoginPage(self.driver) lp.login('admin', '123456') def test_organization(self): hp = HomePage(self.driver) hp.head_portrait() sleep(2) hp.organizational_structure_submit() sleep(2) op = OrganizationPage(self.driver) op.origanization_element() sleep(2) op.alterrole(self.newpartname) # 编辑部门 sleep(2) op.alterrole('华北销售部') sleep(2) op.moveto_delete() # 删除部门 op1 = OrPage(self.driver) op1.add_departmentnamedescription('市场部', 3, '营销工作') sleep(2) op.alter_role(self.newrolename) # 编辑岗位 sleep(2) op.roledelete_element() sleep(2) op1.add_role('销售专员', 6, 7, '负责销售事宜') sleep(2) op.searchuser() sleep(2) self.assertEqual(int(self.expected), op.aserttable_element(), msg='测试不通过') def tearDown(self) -> None: self.driver.quit()