Beispiel #1
0
 def test_a_entry_sigle_phase_exam(self, class_name, score, phase, comment,
                                   expect):
     self.phase_exam.do_entry_sigle_phase_exam(class_name, score, phase,
                                               comment)
     if Service.is_element_present(
             self.driver, By.CSS_SELECTOR,
             'body > div.bootbox.modal.fade.mydialog.in > '
             'div > div'):
         actual = 'test import sigle phase exam fail'
         self.driver.refresh()
     else:
         ele = self.driver.find_element_by_css_selector(
             '#pe-result > tbody > tr:nth-child(1) > '
             'td:nth-child(9) > button')
         attr = ele.get_attribute('onclick')
         attr_dict = attr.split('(')[1].split(')')[0]
         import json
         dict_attr = json.loads(attr_dict, encoding='utf-8')
         student_id = dict_attr['student_id']
         phase1_score = dict_attr['phase1']
         phase2_score = dict_attr['phase2']
         phase3_score = dict_attr['phase3']
         phase4_score = dict_attr['phase4']
         sql = f"select score from phase_exam where phase_exam_student_id ='{student_id}' and phase_exam_class_id = '1' order by phase asc"
         db_result = Utility.query_all('../config/base.conf', sql)
         num = len(db_result)
         if num == 1:
             if float(db_result[0][0]) == float(phase1_score):
                 actual = 'test import sigle phase exam pass'
             else:
                 actual = 'test import sigle phase exam fail'
         elif num == 2:
             if float(db_result[0][0]) == float(phase1_score) and float(
                     db_result[1][0]) == float(phase2_score):
                 actual = 'test import sigle phase exam pass'
             else:
                 actual = 'test import sigle phase exam fail'
         elif num == 3:
             if float(db_result[0][0]) == float(phase1_score) and float(db_result[1][0]) == float(phase2_score) and \
                     float(db_result[2][0]) == float(phase3_score):
                 actual = 'test import sigle phase exam pass'
             else:
                 actual = 'test import sigle phase exam fail'
         elif num == 4:
             if float(db_result[0][0]) == float(phase1_score) and float(db_result[1][0]) == float(phase2_score) and float(db_result[2][0]) == float(phase3_score)\
                      and float(db_result[3][0]) == float(phase4_score):
                 actual = 'test import sigle phase exam pass'
             else:
                 actual = 'test import sigle phase exam fail'
         else:
             actual = 'test import sigle phase exam fail'
     self.assertEqual(expect, actual)
Beispiel #2
0
 def test_login(self, login_userName, login_userPASS, login_checkcode,
                login_expect):
     contents = {
         'username': login_userName,
         'password': login_userPASS,
         'checkcode': login_checkcode
     }
     self.login.excute_login(contents)
     # 断言
     if Service.is_element_present(self.driver, By.PARTIAL_LINK_TEXT, '注销'):
         actual = 'success'
     elif self.driver.find_element_by_id('pwMsg').text == '用户名或密码错误':
         actual = 'error'
     elif self.driver.find_element_by_id('checkcodeMsg').text == '用户名或密码错误':
         actual = 'error'
     else:
         actual = 'error'
     self.assertEqual(actual, login_expect)
Beispiel #3
0
    def test_b_modify_student_info(cls, name, stu_tel, status, fee, person,
                                   connect_tel, school, diploma, major,
                                   id_number, age, expect):
        cls.student_info.do_modify_student_info(name, stu_tel, status, fee,
                                                person, connect_tel, school,
                                                diploma, major, id_number, age)
        time.sleep(5)
        if Service.is_element_present(cls.driver, By.XPATH,
                                      '/html/body/div[12]/div/div/div[2]/div'):
            text = cls.driver.find_element_by_xpath(
                '/html/body/div[12]/div/div/div[2]/div').text
            print(text)
            if '操作成功' in text:
                actual = 'test modify student info pass'
            else:
                actual = 'test modify student info fail'
        else:
            actual = 'test modify student info fail'

        cls.driver.refresh()

        cls.assertEqual(expect, actual)