class TestXaiole(): def test_xiaole(self, browser): '''智能问答''' self.xiaole_page = Loginpage(browser).login('955112', 'a1234567').hi_xiaole() self.xiaole_page.question('三角函数') assert '三角函数' in self.xiaole_page.get_answer()
class TestXaiole_sg(): def test_xiaole_sg(self, browser): '''提建议''' self.xiaole_page = Loginpage(browser).login('955112', 'a1234567').hi_xiaole() self.xiaole_page.suggest('123') assert '小乐收到你的建议啦' in self.xiaole_page.get_request()
def test_wood(self, browser): self.wood_page = Loginpage(browser).login('955112', 'a1234567').woods() self.wood_page.my_forest() self.wood_page.schoolmate() log_time = time.strftime("%Y.%m.%d") assert log_time in self.wood_page.get_log()
def test_operation(self,browser): """ 查看操作页 """ self.loperation_page = Loginpage(browser).login('955194', 'jia1234567@').operation() self.loperation_page.todayplan() self.loperation_page.history() assert 4 == self.loperation_page.taskslen()
def test_continuepay(self, browser): ''' 继续支付 :param browser: :return: ''' self.other_page = Loginpage(browser).login('955194', 'jia1234567@') self.other_page.continue_pay() self.other_page.report()
def test_evaluation(self, browser): ''' 执行智能测评第一步第二步 :param browser: :return: ''' self.evaluation_page = Loginpage(browser).login( '955194', 'jia1234567@').evaluation() self.evaluation_page.start() self.evaluation_page.first_step() self.evaluation_page.second_step()
def test_result(self, browser): ''' 测试结果页、重新测评、调整计划、开启乐学 :param browser: :return: ''' self.result_page = Loginpage(browser).login('955194', 'jia1234567@').result() self.result_page.reevaluation() self.result_page.adjustplan() self.result_page.open()
def p_start(cls): #家长按手机模式启动 mobileEmulation = {'deviceName': 'iPhone X'} options = webdriver.ChromeOptions() options.add_experimental_option('mobileEmulation', mobileEmulation) cls.driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=options) cls.driver.implicitly_wait(10) return Loginpage(cls.driver)
class TestResult(): def test_result(self, browser): ''' 测试结果页、重新测评、调整计划、开启乐学 :param browser: :return: ''' self.result_page = Loginpage(browser).login('955194', 'jia1234567@').result() self.result_page.reevaluation() self.result_page.adjustplan() self.result_page.open() def test_revertdata(self): ''' 数据更新,将此次测试用例得执行数据物理删除 :return: ''' d_ai_order_info = 'delete from ai_order_info where parent_id = 850826 and is_deleted = 0;' d_ai_member_info = 'delete from ai_member_info where parent_id = 850826 and is_deleted = 0;' d_ai_user_test_result = 'DELETE FROM ai_user_test_result WHERE created_by = 850826 and is_deleted = 0;' d_ai_user_test_paper = 'DELETE from ai_user_test_paper WHERE parent_id = 850826 and is_deleted = 0;' d_ai_user_test_report = 'DELETE from ai_user_test_report WHERE parent_id = 850826 and is_deleted = 0;' d_ai_student_plan = 'DELETE from ai_student_plan WHERE parent_id = 850826 and is_deleted = 0;' ai_order_info = 'update ai_order_info set is_deleted = 0 WHERE parent_id = 850826;' ai_member_info = 'update ai_member_info set is_deleted = 0 where parent_id = 850826;' ai_user_test_result = 'update ai_user_test_result set is_deleted = 0 where created_by = 850826;' ai_user_test_paper = 'update ai_user_test_paper set is_deleted = 0 where parent_id = 850826;' ai_user_test_report = 'update ai_user_test_report set is_deleted = 0 where parent_id = 850826;' ai_student_plan = 'update ai_student_plan set is_deleted = 0 where parent_id = 850826;' db = MysqlUtil.getConnect(self) cursor = db.cursor() try: # 执行sql语句 cursor.execute(d_ai_order_info) cursor.execute(d_ai_member_info) cursor.execute(d_ai_user_test_result) cursor.execute(d_ai_user_test_paper) cursor.execute(d_ai_user_test_report) cursor.execute(d_ai_student_plan) db.commit() print('删除数据成功!') cursor.execute(ai_order_info) cursor.execute(ai_member_info) cursor.execute(ai_user_test_result) cursor.execute(ai_user_test_paper) cursor.execute(ai_user_test_report) cursor.execute(ai_student_plan) db.commit() print('更新数据成功!') except: # 如果发生异常,则回滚 db.rollback() finally: # 最终关闭数据库连接 db.close() print("数据库连接关闭!")
class TestLogin(): login_page = Loginpage(browser) def test_findpwd(self, browser): """找回密码""" login_page = Loginpage(browser) login_page.findpwd() assert '重置密码' in login_page.get_findpwd_title() login_page.black() def test_login(self, browser): """登录""" login_page = Loginpage(browser) login_page.login('955112', 'test1234')
def s_start(cls): #学生按分辨率启动 WIDTH = 960 HEIGHT = 600 PIXEL_RATIO = 3.0 UA = 'Mozilla/5.0 (Linux; Android 4.1.1; GT-N7100 Build/JRO03C) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/35.0.1916.138 Mobile Safari/537.36 T7/6.3' mobileEmulation = {"deviceMetrics": {"width": WIDTH, "height": HEIGHT, "pixelRatio": PIXEL_RATIO}, "userAgent": UA} options = webdriver.ChromeOptions() options.add_experimental_option('mobileEmulation', mobileEmulation) cls.driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=options) cls.driver.maximize_window() cls.driver.implicitly_wait(10) return Loginpage(cls.driver)
class TestEvaluation(): def test_update_data(self): ''' 将目前已有计划数据逻辑删除 :return: ''' ai_order_info = 'update ai_order_info set is_deleted = 1 WHERE parent_id = 850826;' ai_member_info = 'update ai_member_info set is_deleted = 1 where parent_id = 850826;' ai_user_test_result = 'update ai_user_test_result set is_deleted = 1 where created_by = 850826;' ai_user_test_paper = 'update ai_user_test_paper set is_deleted = 1 where parent_id = 850826;' ai_user_test_report = 'update ai_user_test_report set is_deleted = 1 where parent_id = 850826;' ai_student_plan = 'update ai_student_plan set is_deleted = 1 where parent_id = 850826;' db = MysqlUtil.getConnect(self) cursor = db.cursor() try: # 执行sql语句 cursor.execute(ai_order_info) cursor.execute(ai_member_info) cursor.execute(ai_user_test_result) cursor.execute(ai_user_test_paper) cursor.execute(ai_user_test_report) cursor.execute(ai_student_plan) db.commit() print('更新数据成功!') except: # 如果发生异常,则回滚 db.rollback() finally: # 最终关闭数据库连接 db.close() print("数据库连接关闭!") def test_evaluation(self, browser): ''' 执行智能测评第一步第二步 :param browser: :return: ''' self.evaluation_page = Loginpage(browser).login( '955194', 'jia1234567@').evaluation() self.evaluation_page.start() self.evaluation_page.first_step() self.evaluation_page.second_step()
def test_login(self, browser): """登录""" self.login_page = Loginpage(browser) self.login_page.login('955112', 'a1234567')
def test_xiaole(self,browser): self.xiaole_page = Loginpage(browser).login('955112', 'a1234567').hi_xiaole() self.xiaole_page.question('三角函数') assert '123' in self.xiaole_page.get_answer()
def test_login(self, browser): """登录""" login_page = Loginpage(browser) login_page.login('955112', 'test1234')
def test_exreport(self,browser): self.exreport_page = Loginpage(browser).login('955112', 'a1234567').exreport() assert '习题报告' in self.exreport_page.get_exreport_title()
def test_cards(self, browser): self.card_page = Loginpage(browser).login('955112', 'a1234567').card() assert 0 <= self.card_page.get_cards_num()
def test_findpwd(self, browser): """找回密码""" login_page = Loginpage(browser) login_page.findpwd() assert '重置密码' in login_page.get_findpwd_title() login_page.black()
def test_add_tc(self, browser): """单个添加老师""" add_page = Loginpage(browser).admin_login('1888xxxxxxxx', 'xxxxxxxx').add_tc() add_page.add_teacher('177777xxxx', 'UI自动化测试', '这是UI自动化数据, 这是UI自动化数据') assert 'UI自动化测试' == add_page.get_tc_name()
def test_add_tcs(self, browser): """批量添加老师""" add_page = Loginpage(browser).admin_login('188888xxxx', 'txxxxxxxx').add_teachers() add_page.import_tcs() assert 'UI自动化批量添加' in add_page.get_im_status()
def test_login(self, browser): """ 登录 """ self.login_page = Loginpage(browser).login('955194', 'jia1234567@')
def test_addpage(self, browser): """是否进入添加老师页面""" add_page = Loginpage(browser).admin_login('188888xxxx', 'xxxxxxxx').add_tc() assert '添加老师' == add_page.get_add_title()
def test_remove_stu(self, browser): name = '' name_list_page = Loginpage(browser).admin_login( '188888xxxx', 'xxxxxxxx').course_manger().name_list() name_list_page.search_stu_name(name) name_list_page.remove_stu()
def test_task(self, browser): self.task_page = Loginpage(browser).login('955112', 'a1234567').task() self.task_page.do_task() #断言已完成角标存在 assert 5 == self.task_page.get_len()
def test_del_live_lesson(self, browser): """删除直播课""" course_page = Loginpage(browser).admin_login( '188888xxxx', 'xxxxxxxx').course_manger() course_page.search_course('UI自动化测试') course_page.del_course()
def test_exercise(self, browser): self.exercise_page = Loginpage(browser).login('955112', 'a1234567').exercise() self.exercise_page.do_exercise()
class TestDemo: def test_login(self,browser): self.login_page = Loginpage(browser) self.login_page.login('955112', 'a1234567')