Ejemplo n.º 1
0
    def test_quit_class(self,CaseId,Module,Title,Precondition,Steps,
                   Data,ExpectedResult,ActualResult,TestResult):
        Data=replace(Data)
        logger.info('正在执行{}条用例,测试数据是{}'.format(CaseId,Data))
        sleep(2)
        password=eval(Data)['password']
        SubCalss().sub_class('python14期考核',password)
        if CaseId==1:
            ele=Login().wait(By.XPATH,"//*[@id='show-tip']")
            msg=ele.text
            try:
                self.assertEqual(ExpectedResult,msg)
                TestResult='pass'
            except AssertionError as e:
                TestResult='failed'
                raise e
        else:
            ele=Login().wait(By.XPATH,"//*[@id='error-tip']")
            msg=ele.text
            try:
                self.assertEqual(ExpectedResult,msg)
                TestResult='pass'
            except AssertionError as e:
                TestResult='failed'
                raise e

        Login().driver.save_screenshot('D:\ketangpai\Data\img\sub_class.png')
        DoExcel(project_path.excel_path).write_Excel('sub',CaseId+1,8,msg)
        DoExcel(project_path.excel_path).write_Excel('sub',CaseId+1,9,TestResult)
        logger.info('测试结果是:{}'.format(TestResult))
Ejemplo n.º 2
0
    def test_add_class(self, CaseId, Module, Title, Precondition, Steps, Data,
                       ExpectedResult, ActualResult, TestResult):

        Data = replace(Data)
        ExpectedResult = replace(ExpectedResult)
        logger.info('正在执行{}条用例,测试数据是{}'.format(CaseId, Data))
        #登录用户
        Login().register('13541781424', '19931025')
        #添加班级
        AddCalss().add_calss(data=eval(Data)['code'])
        sleep(2)
        self.driver.save_screenshot('D:\ketangpai\Data\img\\add_class.png')
        if CaseId == 1:
            #获取班级名称
            ele = Login().wait(
                By.XPATH,
                "//*[@id='viewer-container-lists']//*[@class='jumptoclass']")
            class_name = ele.get_attribute('title')
            try:
                self.assertEqual(ExpectedResult, class_name)
                TestResult = 'pass'
                # 进入课堂
                Login().wait(By.XPATH, "//a[@title='py14期考核']").click()
                sleep(2)
                Login().driver.save_screenshot(
                    'D:\ketangpai\Data\img\class.png')
                Login().driver.back()
            except AssertionError as e:
                TestResult = 'failed'
                raise e
        else:
            class_name = Login().wait(By.XPATH, "//*[@id='error-tip']").text
            try:
                self.assertEqual(ExpectedResult, class_name)
                TestResult = 'pass'
            except AssertionError as e:
                TestResult = 'failed'
                raise e
        '''写回测试结果'''
        DoExcel(project_path.excel_path).write_Excel('add', CaseId + 1, 8,
                                                     class_name)
        DoExcel(project_path.excel_path).write_Excel('add', CaseId + 1, 9,
                                                     TestResult)
        logger.info('测试结果是:{}'.format(TestResult))
Ejemplo n.º 3
0
 def test_add_class(self, CaseId, Module, Title, Precondition, Steps, Data,
                    ExpectedResult, ActualResult, TestResult):
     Data = replace(Data)
     ExpectedResult = replace(ExpectedResult)
     logger.info('正在执行{}条用例,测试数据是{}'.format(CaseId, Data))
     #点击加入班级
     Login().wait(
         By.XPATH,
         "//*[text()='加入班级' and contains(@class,'ktcon1l')]").click()
     #定位输入框
     ele = Login().wait(By.XPATH, "//*[@class='chuangjiankccon']/input")
     #输入验证码
     ele.send_keys(eval(Data)['code'])
     #点击加入按钮
     Login().wait(By.XPATH, "//*[@class='cjli2']/a").click()
     sleep(2)
     self.driver.save_screenshot('D:\ketangpai\Data\img\\add_class.png')
     #获取班级名称
     ele = Login().wait(
         By.XPATH,
         "//*[@id='viewer-container-lists']//*[@class='jumptoclass']")
     class_name = ele.get_attribute('title')
     try:
         self.assertEqual(ExpectedResult, class_name)
         TestResult = 'pass'
     except AssertionError as e:
         TestResult = 'failed'
         raise e
     finally:
         '''写回测试结果'''
         DoExcel(project_path.excel_path).write_Excel(
             'web', CaseId + 1, 8, class_name)
         DoExcel(project_path.excel_path).write_Excel(
             'web', CaseId + 1, 9, TestResult)
         # 进入课堂
         Login().wait(By.XPATH, "//a[@title='py14期考核']").click()
         sleep(2)
         Login().driver.save_screenshot('D:\ketangpai\Data\img\class.png')
         Login().driver.back()
Ejemplo n.º 4
0
    def test_quit_class(self, CaseId, Module, Title, Precondition, Steps, Data,
                        ExpectedResult, ActualResult, TestResult):
        Data = replace(Data)
        if Module == 'quit':
            logger.info('正在执行{}条用例,测试数据是{}'.format(CaseId, Data))
            #定位三个点
            Login().wait(
                By.XPATH,
                "//*[@data-id='MDAwMDAwMDAwMLOsuZmIqcmw']//a[@class='kdmore']"
            ).click()
            #点击退课
            # Login().wait(By.XPATH,"//*[@data-id='MDAwMDAwMDAwMLOsuZmHz9Fo']//a[text()='退课']").click()
            ac = ActionChains(Login().driver)
            ele = Login().wait(By.XPATH, "//*[text()='退课']")
            ac.move_to_element(ele).click(ele).perform()
            #输入密码
            Login().wait(
                By.XPATH,
                "//*[@class='deletekccon']//input").send_keys('19931025')
            #点击退课
            Login().wait(By.XPATH,
                         "//*[@class='deletekt']//*[text()='退课']").click()
            sleep(2)
            Login().driver.save_screenshot(
                'D:\ketangpai\Data\img\sub_class.png')

            ele = Login().wait(
                By.XPATH,
                "//*[@id='viewer-container-lists']//*[@class='jumptoclass']")
            end_name = ele.get_attribute('title')
            try:
                self.assertNotEqual(ExpectedResult, end_name)
                TestResult = 'pass'
            except AssertionError as e:
                TestResult = 'failed'
                raise e
            finally:
                '''写回测试结果'''
                DoExcel(project_path.excel_path).write_Excel(
                    'web', CaseId + 1, 8, end_name)
                DoExcel(project_path.excel_path).write_Excel(
                    'web', CaseId + 1, 9, TestResult)
                logger.info('测试结果是:{}'.format(TestResult))
Ejemplo n.º 5
0
    def test_add_class(self, CaseId, Module, Title, Precondition, Steps, Data,
                       ExpectedResult, ActualResult, TestResult):
        Data = replace(Data)
        logger.info('正在执行{}条用例,测试数据是{}'.format(CaseId, Data))
        #点击加入班级
        Login().wait(
            By.XPATH,
            "//*[text()='加入班级' and contains(@class,'ktcon1l')]").click()
        #定位输入框
        ele = Login().wait(By.XPATH, "//*[@class='chuangjiankccon']/input")
        #输入验证码
        ele.send_keys(eval(Data)['code'])
        #点击加入按钮
        Login().wait(By.XPATH, "//*[@class='cjli2']/a").click()
        sleep(2)
        self.driver.save_screenshot('D:\ketangpai\Data\img\\add_class.png')
        #获取班级名称
        ele = Login().wait(
            By.XPATH,
            "//*[@data-id='MDAwMDAwMDAwMLOsuZmHz9Fo']//*[@class='jumptoclass']"
        )
        class_name = ele.get_attribute('title')
        try:
            self.assertEqual(ExpectedResult, class_name)
        except AssertionError as e:
            raise e
        finally:
            '''写回测试结果'''
            DoExcel(project_path.excel_path).write_Excel(
                'web', CaseId + 1, 8, class_name)
            DoExcel(project_path.excel_path).write_Excel(
                'web', CaseId + 1, 9, TestResult)

        #进入课堂
        Login().wait(By.XPATH, "//a[@title='python14期考核']").click()
        sleep(2)
        self.driver.save_screenshot('D:\ketangpai\Data\img\class.png')
        self.driver.back()
        #定位三个点
        Login().wait(
            By.XPATH,
            "//*[@data-id='MDAwMDAwMDAwMLOsuZmHz9Fo']//a[@class='kdmore']"
        ).click()
        #点击退课
        Login().wait(
            By.XPATH,
            "//*[@data-id='MDAwMDAwMDAwMLOsuZmHz9Fo']//a[text()='退课']").click(
            )
        #输入密码
        Login().wait(By.XPATH,
                     "//*[@class='deletekccon']//input").send_keys('19931025')
        #点击退课
        Login().wait(By.XPATH,
                     "//*[@class='deletekt']//*[text()='退课']").click()
        sleep(2)
        self.driver.save_screenshot('D:\ketangpai\Data\img\sub_class.png')

        ele = Login().wait(
            By.XPATH,
            "//*[@data-id='MDAwMDAwMDAwMLOcz5mGqclt']//*[@class='jumptoclass']"
        )
        end_name = ele.get_attribute('title')
        try:
            self.assertNotEqual(ExpectedResult, end_name)
            TestResult = 'pass'
        except AssertionError as e:
            TestResult = 'failed'
            raise e
        finally:
            '''写回测试结果'''
            DoExcel(project_path.excel_path).write_Excel(
                'web', CaseId + 1, 8, end_name)
            DoExcel(project_path.excel_path).write_Excel(
                'web', CaseId + 1, 9, TestResult)
            logger.info('测试结果是:{}'.format(TestResult))