class Cases(unittest.TestCase): def setUp(self): self.driver = LoginPage() self.driver.login_action() self.mainPage = MainPage(self.driver.driver) self.mainSchPage = MainSchedulePage(self.driver.driver) self.meetingPage = AddMeetingPage(self.driver.driver) def test_nomarl_meeting(self): self.mainPage.click_schedule_button() self.mainSchPage.new_meeting_click() self.meetingPage.create_meeting()
def test_login3(self): """密码不正确""" case_name = '密码不正确' log1.info("执行测试用例:%s" % case_name) login = LoginPage(self.driver) login.login('xuhaixiang1993', ' 12314') error_text = login.get_login_error() try: self.assertEqual(error_text, 'Incorrect username or password.') log1.info("测试用例执行成功:%s" % case_name + '\n') except AssertionError: log1.error("测试用例执行失败:%s" % case_name + '\n') raise
def test_login1(self): """用户名为空""" case_name = '用户为空' log1.info("执行测试用例:%s" % case_name) login = LoginPage(self.driver) login.login(' ', '12324') error_text = login.get_login_error() try: self.assertEqual(error_text, 'Incorrect username or password.') log1.info("测试用例执行成功:%s" % case_name + '\n') except AssertionError: log1.error("测试用例执行失败:%s" % case_name + '\n') raise
def test_login3(self): """密码不正确""" case_name = '密码不正确' log1.info("执行测试用例:%s" % case_name) login = LoginPage(self.driver) login.login('WQ68', '12314') error_text = login.get_login_error2() try: self.assertEqual(error_text, '用户名或密码错误,再输错4次该用户将被锁定15分钟。') log1.info("测试用例执行成功:%s" % case_name + '\n') except AssertionError: log1.error("测试用例执行失败:%s" % case_name + '\n') raise
def test_login2(self): """密码为空""" case_name = '密码为空' log1.info("执行测试用例:%s" % case_name) login = LoginPage(self.driver) login.login('LJDY1077', '') error_text = login.get_login_error() try: self.assertEqual(error_text, '密码不能为空。') log1.info("测试用例执行成功:%s" % case_name + '\n') except AssertionError: log1.error("测试用例执行失败:%s" % case_name + '\n') raise
def test_login4(self): """登录成功""" # 想要执行成功,需使用GitHub账号和密码 case_name = '登录成功' log1.info("执行测试用例:%s" % case_name) login = LoginPage(self.driver) login.login('username', 'password') login_title = login.get_title() try: self.assertEqual(login_title, 'GitHub') log1.info("测试用例执行成功:%s" % case_name + '\n') except AssertionError: log1.error("测试用例执行失败:%s" % case_name + '\n') raise
def login_page_class_load(function_driver): """ 注入等页面对象 @param function_driver: @return: """ login_page = LoginPage(function_driver) yield login_page
def tearDownClass(cls): login = LoginPage(cls.driver) login.dr_quit()
def setUp(self): self.driver = LoginPage() self.driver.login_action() self.mainPage = MainPage(self.driver.driver) self.mainSchPage = MainSchedulePage(self.driver.driver) self.meetingPage = AddMeetingPage(self.driver.driver)
def test_login_fail(self): LoginPage(self.driver).login('1111', '123121') fail_title = LoginPage(self.driver).get_title() self.driver.implicitly_wait(3) # 断言 assert fail_title == '懂王app管理后台'
def test_login_success(self): LoginPage(self.driver).login('wxk', '123456') successText = LoginPage(self.driver).get_success_info() self.driver.implicitly_wait(3) # 断言 assert successText == '懂王app管理后台'
def test_addAdv(self): LoginPage(self.driver).login('wxk', '123456') AdvPage(self.driver).addAdv(data['time'], data['img_url'], data['title'], data['h5_url'], data['start_time'], data['end_time'])