Example #1
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.wd = WebDriverDoBeforeTest()
     self.wd.className ="login_lab.Login"
     self.wd.beforeClass()
     
     self.logger = LogObj()
     
     self.weblogin = web_login()
     self.weblogin.back_LoginPage(5)
     self.driver = self.weblogin.driver
     self.em = ExcelManager("UsersLogin.xls")
Example #2
0
    def setUp(self):
        unittest.TestCase.setUp(self)

        self.wd = WebDriverDoBeforeTest()
        self.wd.className = "studentSignin.Signin"
        self.wd.beforeClass()

        self.logger = LogObj()

        self.weblogin = web_login()
        self.weblogin.back_SigninPage()  #返回到student 签到的页面

        self.webdriverpai = WebdriverApi(self.weblogin.driver)
        self.em = ExcelManager("UsersLogin.xls")
Example #3
0
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.wd = WebDriverDoBeforeTest()
        self.wd.className = "Class_Management"
        self.wd.beforeClass()

        self.logger = LogObj()

        self.weblogin = web_login()
        self.weblogin.back_LoginPage(3)

        self.driver = self.weblogin.driver
        self.driverapi = WebdriverApi(self.driver)

        self.em = ExcelManager("UsersLogin.xls")
Example #4
0
class Login(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.wd = WebDriverDoBeforeTest()
        self.wd.className ="login_lab.Login"
        self.wd.beforeClass()
        
        self.logger = LogObj()
        
        self.weblogin = web_login()
        self.weblogin.back_LoginPage(5)
        self.driver = self.weblogin.driver
        self.em = ExcelManager("UsersLogin.xls")
        
    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.wd.afterClass()
        self.driver.close()
    
    def test_login_labPlatf(self):
        '''身份登录测试用例'''
        self.logger.info("Login.test_login_labPlatf测试用例已执行")
        tes_xls_data = self.em.readexcel("users")  #得到sheet页
        nrows = tes_xls_data.nrows
        print "------ excel中的测试用例条数是:",nrows-1    #excel中 的数据行数从1行开始
        for i in range(1,nrows):       #for循环式,默认从0--n-1
            print "------ 这是第:",i," 条用例"
            row_A = tes_xls_data.cell(i,0).value
            row_B = tes_xls_data.cell(i,1).value
            row_C = tes_xls_data.cell(i,2).value
            print row_A, row_B, row_C
            b = self.weblogin.userType_login(row_A, row_B, row_C)
            if b:
                title = self.driver.title
                print title
                if "实验室数字化平台" == title:               
                    print "------ 登录成功  ------"
                    self.em.writexcel(i, 3, "pass")
                    self.weblogin.back_LoginPage(5)
            else:
                print "------ 登录失败  ------"
                self.em.writexcel(i, 3, "failed")
                self.weblogin.back_LoginPage(5)
        print "------ 登录测试用例执行成功 ------"
Example #5
0
class SignIn(unittest.TestCase):

    def setUp(self):
        unittest.TestCase.setUp(self)
        self.logger = LogObj()
        
        self.weblogin = web_login()
        self.weblogin.back_SigninPage() #返回到student 签到的页面
        
        self.wd = WebDriverDoBeforeTest()
        self.wd.className ="studentSignin.Signin"
        self.wd.beforeClass()
        self.wd.driver = self.weblogin.driver   
        
        self.webdriverpai = WebdriverApi(self.weblogin.driver)
        self.em = ExcelManager("UsersLogin.xls")
    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.wd.afterClass()
        self.weblogin.driver.close()

    def test_student_singin(self):
        '''学生签到测试用例'''
        try:
            self.logger.info("SignIn.test_student_singin 测试用例已执行")
            api = self.webdriverpai
            
            tes_xls_data = self.em.readexcel("students")  #得到sheet页
            nrows = tes_xls_data.nrows
            print "------ excel中的测试用例条数是:",nrows-1    #excel中 的数据行数从1行开始
            for i in range(1,nrows):       #for循环式,默认从0--n-1
                print "------ 这是第:",i," 条用例"
                row_A = str(tes_xls_data.cell(i,0).value)
                row_B = str(tes_xls_data.cell(i,1).value)
                row_C = tes_xls_data.cell(i,2).value
                print row_A, row_B, row_C 
                
                api.webList_RandomSelectByOption(By.ID, "class_id", 3)
                api.webList_RandomSelectByOption(By.ID, "lab_id", 3)
                api.sendKeys(By.ID, "name",row_A)
                api.sendKeys(By.ID, "stuno",row_B)
                api.sendKeys(By.ID, "info",row_C)
                api.click(By.ID, "sign")
                b = api.is_Displayed(By.CLASS_NAME,"layui-layer-btn0")
                if b:
                    capturename = api.getText(By.CLASS_NAME, "layui-layer-content")
                    if "欢迎使用实验室数字化平台签到" != capturename:
                        self.wd.capture(capturename)
                        api.click(By.CLASS_NAME,"layui-layer-btn0")
                self.weblogin.back_SigninPage() #返回到student 签到的页面
        except Exception,e:
                self.logger.error("SignIn.test_student_singin 测试用例出现异常"+str(e))
Example #6
0
class SignIn(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)

        self.wd = WebDriverDoBeforeTest()
        self.wd.className = "studentSignin.Signin"
        self.wd.beforeClass()

        self.logger = LogObj()

        self.weblogin = web_login()
        self.weblogin.back_SigninPage()  #返回到student 签到的页面

        self.webdriverpai = WebdriverApi(self.weblogin.driver)
        self.em = ExcelManager("UsersLogin.xls")

    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.wd.afterClass()
        self.weblogin.driver.close()

    def test_student_singin(self):
        try:
            self.logger.info("SignIn.test_student_singin 测试用例已执行")
            driver = self.weblogin.driver
            api = self.webdriverpai
            tes_xls_data = self.em.readexcel("students")  #得到sheet页
            nrows = tes_xls_data.nrows
            print "------ excel中的测试用例条数是:", nrows - 1  #excel中 的数据行数从1行开始
            for i in range(1, nrows):  #for循环式,默认从0--n-1
                print "------ 这是第:", i, " 条用例"
                row_A = tes_xls_data.cell(i, 0).value
                row_B = tes_xls_data.cell(i, 1).value
                row_C = tes_xls_data.cell(i, 2).value
                print row_A, row_B, row_C

                clss = Select(driver.find_element_by_id("class_id")).options
                random.choice(clss).click()
                driver.implicitly_wait(2)

                lab = Select(driver.find_element_by_id("lab_id")).options
                random.choice(lab).click()
                driver.implicitly_wait(2)

                driver.find_element_by_id("name").clear()
                driver.find_element_by_id("name").send_keys(row_A)
                driver.implicitly_wait(2)

                driver.find_element_by_id("stuno").clear()
                driver.find_element_by_id("stuno").send_keys(row_B)
                driver.implicitly_wait(2)

                driver.find_element_by_id("info").clear()
                driver.find_element_by_id("info").send_keys(row_C)
                driver.implicitly_wait(2)

                driver.find_element_by_id("sign").click()

                b = driver.find_element_by_class_name(
                    "layui-layer-btn0").is_displayed()

                if b:
                    driver.find_element_by_class_name(
                        "layui-layer-btn0").click()

                self.weblogin.back_SigninPage()  #返回到student 签到的页面
        except Exception, e:
            self.logger.error("SignIn.test_student_singin 测试用例出现异常" + str(e))
Example #7
0
class Class_Management(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.wd = WebDriverDoBeforeTest()
        self.wd.className = "Class_Management"
        self.wd.beforeClass()

        self.logger = LogObj()

        self.weblogin = web_login()
        self.weblogin.back_LoginPage(3)

        self.driver = self.weblogin.driver
        self.driverapi = WebdriverApi(self.driver)

        self.em = ExcelManager("UsersLogin.xls")

    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.driver.close()
        self.wd.afterClass()

    def test_ClassManagement(self):
        '''网站管理员班级管理测试用例'''
        self.logger.info("Class_Management.test_ClassManagement测试用例已执行")
        api = self.driverapi
        loginlab = self.weblogin

        tes_xls_data = self.em.readexcel("users")
        nrows = tes_xls_data.nrows
        for i in range(1, nrows):
            typeNum = tes_xls_data.cell(i, 2).value
            if typeNum == '4':
                user = tes_xls_data.cell(i, 0).value
                passwd = tes_xls_data.cell(i, 1).value
                print "实验室管理员账号密码及类型", user, passwd, typeNum
                b = loginlab.userType_login(user, passwd, typeNum)
                if b:
                    api.click(By.XPATH, "//a[@href='classmanage']")
                    boolean = True
                    while boolean:

                        api.click(By.ID, "ref_but")
                        api.click(By.ID, "add_clazz_but")

                        api.webList_RandomSelectByOption(By.ID, "grade_id", 5)
                        api.webList_RandomSelectByOption(By.ID, "major_id", 5)
                        api.webList_RandomSelectByOption(By.ID, "class_no", 5)
                        api.click(By.ID, "save_clazz_but")

                        bb = api.is_Displayed(By.CLASS_NAME,
                                              "layui-layer-content")
                        if bb:
                            content = api.getText(By.CLASS_NAME,
                                                  "layui-layer-content")
                            if "班级信息存在" == content:
                                api.click(By.CLASS_NAME, "layui-layer-btn0")
                                continue
                            else:
                                api.click(By.CLASS_NAME, "layui-layer-btn0")
                                api.click(By.CLASS_NAME, "close")
                                boolean = False
                break
        print "班级管理测试用例通过"
Example #8
0
class LaboratoryManagement(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.wd = WebDriverDoBeforeTest()
        self.wd.className = "LaboratoryManagement"
        self.wd.beforeClass()

        self.logger = LogObj()

        self.weblogin = web_login()
        self.weblogin.back_LoginPage(3)

        self.driver = self.weblogin.driver
        self.driverapi = WebdriverApi(self.driver)

        self.em = ExcelManager("UsersLogin.xls")

    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.driver.close()
        self.wd.afterClass()

    def test_LaboratoryManagement(self):
        '''实验员管理测试用例'''
        self.logger.info(
            "LaboratoryManagement.test_LaboratoryManagement测试用例已执行")
        api = self.driverapi
        loginlab = self.weblogin

        tes_xls_data = self.em.readexcel("users")
        nrows = tes_xls_data.nrows
        for i in range(1, nrows):
            typeNum = tes_xls_data.cell(i, 2).value
            if typeNum == '2':
                user = tes_xls_data.cell(i, 0).value
                passwd = tes_xls_data.cell(i, 1).value
                print "实验室管理员账号密码及类型", user, passwd, typeNum
                b = loginlab.userType_login(user, passwd, typeNum)
                if b:
                    api.click(By.XPATH, "//a[@href='lab_tech']")
                    api.click(By.ID, "ref_but")
                    api.click(By.ID, "add_lab_tech_but")

                    num = random.randint(1, 20)
                    newname = "jayzhen" + str(num)
                    api.sendKeys(By.ID, "lab_tech_name_text", newname)

                    newemail = "*****@*****.**"
                    api.sendKeys(By.ID, "lab_tech_email_text", newemail)

                    newqq = str(random.randint(111111, 999999999))
                    api.sendKeys(By.ID, "lab_tech_qq_text", newqq)

                    newphone = str(random.randint(18311111111, 18399999999))
                    api.sendKeys(By.ID, "lab_tech_phone_text", newphone)

                    api.webList_RandomSelectByOption(By.ID, "lab_id", 3)

                    api.click(By.ID, "save_lab_tech_but")

                    bb = api.is_Displayed(By.CLASS_NAME, "layui-layer-btn0")
                    if bb:
                        errorcont = api.getText(By.CLASS_NAME,
                                                "layui-layer-btn0")
                        self.logger.debug("填完新增实验员的内容后,点击确定,提示:%s" % errorcont)
                        api.click(By.CLASS_NAME, "layui-layer-btn0")
                    api.click(By.CLASS_NAME, "close")
        print "实验室管理测试用例通过"
Example #9
0
class ApplyLab(unittest.TestCase):

    def setUp(self):
        unittest.TestCase.setUp(self)
        self.wd = WebDriverDoBeforeTest()
        self.wd.className ="ApplyLab"
        self.wd.beforeClass()
        
        self.logger = LogObj()
        
        self.weblogin = web_login()
        self.weblogin.back_LoginPage(3)
        
        self.driver = self.weblogin.driver
        self.driverapi = WebdriverApi(self.driver)
        
        self.em = ExcelManager("UsersLogin.xls")
    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.driver.close()
        self.wd.afterClass()

    def test_ApplyLab(self):
        '''教师申请实验室用例'''
        self.logger.info("ApplyLab.test_ApplyLab测试用例已执行")
        api = self.driverapi
        loginlab = self.weblogin
        
        tes_xls_data = self.em.readexcel("users")  
        nrows = tes_xls_data.nrows
        
        for i in range(1,nrows):       
            typeNum = tes_xls_data.cell(i,2).value
            if typeNum == '3': 
                user = tes_xls_data.cell(i,0).value
                passwd = tes_xls_data.cell(i,1).value   
                print "实验室管理员账号密码及类型",user, passwd, typeNum 
                b = loginlab.userType_login(user, passwd, typeNum) 
                if b:
                    api.click(By.XPATH, "//a[@href='apply']")
                    api.webList_RandomSelectByOption(By.ID,"year_id", 2)
                    api.webList_RandomSelectByOption(By.ID,"lab_id", 2)
                    api.webList_RandomSelectByOption(By.ID,"class_id", 2)
                    api.webList_RandomSelectByOption(By.ID,"course_id", 2)
                    
                    bb = True
                    while bb :
                        begin = random.randint(1,68)
                        api.sendKeys(By.ID, "ksjc", str(begin))
                        end = random.randint(begin+1,begin+3)
                        api.sendKeys(By.ID, "jsjc", str(end))
                        show = api.getText(By.ID, "ErrorInfo")
                        
                        ebtn = api.is_Displayed(By.CLASS_NAME, "layui-layer-btn0")
                        if ebtn:
                            api.click(By.CLASS_NAME, "layui-layer-btn0")
                            continue
                        if show.strip()=="":
                            bb = False
                            print "执行选择周次"
                            beginWeek = random.randint(1,4)
                            api.selectByValue(By.ID,"kszc",str(beginWeek), 5)
                            endWeek = random.randint(beginWeek+1,beginWeek+5)
                            print "结束周次是:%s"%endWeek
                            api.selectByValue(By.ID,"jszc",str(endWeek), 5)
                        self.logger.debug("课时选择提示:%s"%show)
                        
                    api.click(By.ID, "check_but")
                    show2 = api.getText(By.ID, "ErrorInfo")
                    if "可申请,请点击右侧申请按钮进行申请" == show2:
                        api.click(By.ID, "apply_but")
                        api.click(By.CLASS_NAME, "layui-layer-btn0")
                        result = api.getText(By.CLASS_NAME,"layui-layer-content")
                        self.logger.debug("申请实验室的结果:%s" %result)
                        api.click(By.CLASS_NAME, "layui-layer-btn0")

        print "申请实验室测试用例通过"
class PersonalCenter(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.wd = WebDriverDoBeforeTest()
        self.wd.className = "PersonalCenter"
        self.wd.beforeClass()

        self.logger = LogObj()

        self.weblogin = web_login()
        self.weblogin.back_LoginPage(3)

        self.driver = self.weblogin.driver
        self.driverapi = WebdriverApi(self.driver)

        self.em = ExcelManager("UsersLogin.xls")

    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.driver.close()
        self.wd.afterClass()

    def test_tester_Personal_Center(self):
        '''实验员个人中心测试用例'''
        self.logger.info(
            "test_PersonalCenter.test_tester_Personal_Center测试用例已执行")
        api = self.driverapi
        loginlab = self.weblogin

        tes_xls_data = self.em.readexcel("users")
        nrows = tes_xls_data.nrows

        for i in range(1, nrows):  #for循环式,默认从0--n-1
            typeNum = tes_xls_data.cell(i, 2).value
            if typeNum == '1':
                user = tes_xls_data.cell(i, 0).value
                passwd = tes_xls_data.cell(i, 1).value
                print "实验室实验员账号密码及类型", user, passwd, typeNum

                b = loginlab.userType_login(user, passwd, typeNum)
                if b:
                    api.click(By.XPATH, "//a[@href='myinfo']")
                    api.click(By.ID, "ref_but")
                    api.click(By.ID, "update_myinfo_but")

                    oldname = api.getText(By.ID, "show_name")
                    #api.sendKeys(By.ID, "input_name_text", oldname)

                    oldemail = api.getText(By.ID, "show_email")
                    #api.sendKeys(By.ID, "input_email_text",oldemail )

                    newQQ = "1157757910"
                    api.sendKeys(By.ID, "input_tencentno_text", newQQ)

                    newPhone = "18511403089"
                    api.sendKeys(By.ID, "input_phone_text", newPhone)

                    bb = api.isSelected(By.ID, "is_change_pw")
                    if bb is False:
                        api.scrollbar_SlideTOBottom('main_table_left_box')
                        api.click(By.ID, "is_change_pw")
                        newPW = "123456"
                        api.sendKeys(By.ID, "input_pw_text", newPW)
                        api.click(By.ID, "go_update_myinfo_but")
                        api.accept_alert()
                        loginlab.back_LoginPage(2)
                        self.logger.debug(
                            "个人中心信息修改为:%s::%s::%s::%s::%s" %
                            (oldname, oldemail, newQQ, newPhone, newPW))
        print "个人中心信息修改测试用例通过"