예제 #1
0
class testTime(object):
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.cmf = commonFun(driver)
        self.frameElem = frameElement(driver)
        self.command = CommandRule(driver)
        self.comsuit = CommonSuiteData(driver)
        self.timerule = TimeRule(driver)
        self.getElem = getElement(driver)
        self.loginElem = loginPage(self.driver)

    u'''提示内容框元素路径'''

    def div_msg(self):
        div_msg = "html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
        return div_msg

    u'''获取测试数据
	   Parameters:
	      - sheetname:sheet名称
	   return:表格数据
	'''

    def get_table_data(self, sheetname):
        dataFile = dataFileName()
        timerulPath = dataFile.get_timerule_test_data_url()
        timerulData = dataFile.get_data(timerulPath, sheetname)
        return timerulData

    u'''添加时间规则'''

    def add_time_rule_001(self):

        #日志开始记录
        self.log.log_start("add_time_rule")
        #获取添加时间规则测试数据
        timerulData = self.get_table_data("add_time_rule")
        #保存成功的弹出框
        comrulMsg = self.div_msg()

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(timerulData)):
            data = timerulData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.command.click_add_button()
                    self.timerule.set_rulename((data[2]))
                    self.timerule.select_depart(data[3])
                    self.timerule.start_date(data[4])
                    self.timerule.date_of_termination(data[6], data[7])
                    self.timerule.set_status_type(data[8])
                    self.timerule.set_time(data[9], data[10], data[11])
                    self.timerule.set_descrip(data[12])
                    self.timerule.click_save_time()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", comrulMsg, data,
                                                  flag)
                    self.command.click_back_command()
                    self.comsuit.switch_to_moudle(u'运维管理', u'用户')
                    self.timerule.edit_user_time_rule(data[13], data[14])
                    if dataRow != 5:
                        self.comsuit.switch_to_moudle(u'运维管理', u'规则定义')
                        self.command.click_left_rule(1)
            except Exception as e:
                print("add_time_rule fail:" + str(e))
        self.comsuit.user_quit()
        self.log.log_end("add_time_rule")

    u'''添加时间规则结果'''

    def add_time_rule_result_002(self):

        #日志开始记录
        self.log.log_start("add_time_rule_result")
        #获取添加时间规则测试数据
        timerulData = self.get_table_data("add_time_rule")
        #保存成功的弹出框
        comrulMsg = self.div_msg()

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(timerulData)):
            data = timerulData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    list = [data[15], data[16], data[17], data[18], data[19]]
                    self.loginElem.login(list)
                    self.frameElem.from_frame_to_otherFrame("topFrame")
                    if self.getElem.is_element_exsit('id', "logout"):
                        self.comsuit.user_quit()
                    else:
                        self.cmf.click_login_msg_button()
                    flag = True
                    self.cmf.test_win_check_point("xpath", comrulMsg, list,
                                                  flag)
            except Exception as e:
                print("add_time_rule_result fail:" + str(e))
        self.comsuit.login_secadmin()
        self.comsuit.switch_to_moudle(u'运维管理', u'规则定义')
        self.command.click_left_rule(1)
        self.log.log_end("add_time_rule_result")

    u'''编辑时间规则'''

    def mod_time_rule_003(self):
        #日志开始记录
        self.log.log_start("mod_time_rule")
        #获取编辑时间规则测试数据
        timerulData = self.get_table_data("mod_time_rule")
        #保存成功的弹出框
        comrulMsg = self.div_msg()

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(timerulData)):
            data = timerulData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.timerule.click_edit_time(data[2])
                    self.timerule.set_rulename((data[3]))
                    self.timerule.start_date(data[4])
                    self.timerule.date_of_termination(data[5], data[6])
                    self.timerule.set_status_type(data[7])
                    self.timerule.deselect_time(data[8], data[9], data[10])
                    self.timerule.set_time(data[11], data[12], data[13])
                    self.timerule.set_descrip(data[14])
                    self.timerule.click_save_time()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", comrulMsg, data,
                                                  flag)
                    self.command.click_back_command()
            except Exception as e:
                print("mod_time_rule fail:" + str(e))
        self.log.log_end("mod_time_rule")

    u'''校验时间规则'''

    def check_time_rule_004(self):
        #日志开始记录
        self.log.log_start("check_time_rule")
        #获取校验时间规则测试数据
        timerulData = self.get_table_data("check_time_rule")
        #保存成功的弹出框
        comrulMsg = self.div_msg()

        self.command.click_add_button()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(timerulData)):
            data = timerulData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 2 or dataRow == 3:
                    self.timerule.set_rulename((data[2]))
                elif dataRow == 4:
                    self.timerule.select_depart(data[3])
                elif dataRow == 5:
                    self.timerule.start_date(data[4], data[5])
                elif dataRow == 6:
                    self.timerule.date_of_termination(data[6], data[7])
                elif dataRow == 7:
                    self.timerule.start_date(data[4])
                elif dataRow == 8 or dataRow == 9:
                    self.timerule.set_time(data[8], data[9], data[10])
                if dataRow != 0:
                    self.timerule.click_save_time()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", comrulMsg, data,
                                                  flag)
            except Exception as e:
                print("check_time_rule fail:" + str(e))
        self.command.click_back_command()
        self.log.log_end("check_time_rule")

    u'''检索时间规则'''

    def query_time_rule_005(self):
        #日志开始记录
        self.log.log_start("query_time_rule")
        #获取检索时间规则测试数据
        timerulData = self.get_table_data("query_time_rule")

        for dataRow in range(len(timerulData)):
            data = timerulData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.timerule.click_reset_time()
                    if dataRow != 4:
                        self.timerule.set_search_timename((data[1]))
                    self.timerule.click_search_time()
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("query_time_rule fail:" + str(e))
        self.log.log_end("query_time_rule")

    u'''删除时间规则'''

    def del_time_rule_006(self):
        #日志开始记录
        self.log.log_start("del_time_rule")
        #获取删除时间规则测试数据
        timerulData = self.get_table_data("del_time_rule")
        #保存成功的弹出框
        comrulMsg = self.div_msg()

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(timerulData)):
            data = timerulData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    if dataRow == 1:
                        self.timerule.click_bulkdel_time()
                        self.cmf.click_login_msg_button()
                        self.log.log_detail(data[0], True)
                    else:
                        self.timerule.click_del_time(data[2])
                        self.frameElem.switch_to_content()
                        self.cmf.test_win_check_point("xpath", comrulMsg, data,
                                                      flag)
                        self.cmf.click_login_msg_button()
            except Exception as e:
                print("del_time_rule fail:" + str(e))
        self.log.log_end("del_time_rule")
예제 #2
0
class testAuthMethod(object):

    #提示框文件元素路径
    def auth_method_msg(self):
        auth_method_msg = "html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
        return auth_method_msg

    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.authMethod = AuthMethodPage(driver)
        self.cmf = commonFun(driver)
        self.getElem = getElement(driver)
        self.selectElem = selectElement(driver)
        self.frameElem = frameElement(driver)
        self.login = loginPage(self.driver)
        self.cnEnde = cnEncode()
        self.commonSuite = CommonSuiteData(self.driver)

    u'''获取测试数据
		Parameters:
			- sheetname:sheet名称
			return:表格数据
	'''

    def get_table_data(self, sheetname):
        dataFile = dataFileName()
        filePath = dataFile.get_auth_method_test_data_url()
        authFileData = dataFile.get_data(filePath, sheetname)
        return authFileData

    u'''校验有弹出框类型用例是否通过
			parameters: 
				data : 检查点
				flag : 通过标识(True or False)
	'''

    def check_with_pop_up(self, data, flag):

        #点击保存按钮弹出框
        auth_method_msg = self.auth_method_msg()
        self.frameElem.switch_to_content()
        self.cmf.test_win_check_point("xpath", auth_method_msg, data, flag)

    u'''添加AD域认证方式'''

    def add_ad_method_001(self):
        #全部认证方式
        all_auth_method = "all_globalAuthMethod"
        #已选认证方式
        selectd_auth_method = "select_globalAuthMethod"

        selem = self.getElem.find_element_with_wait("id", selectd_auth_method)
        self.authMethod.selectd_all_method(selem, '2')
        #日志开始记录
        self.log.log_start("addADMethod")
        #获取添加系统管理员测试数据
        auth_method_data = self.get_table_data("add_auth_method")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(auth_method_data)):
            data = auth_method_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 1:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.authMethod.select_add_meth_method(data[2])
                    self.authMethod.auth_add_button()
                    self.authMethod.check_option_is_not_exist(
                        'id', all_auth_method, data[3])
                    #校验是否添加到已选认证方式
                    self.authMethod.check_option_is_selectd(
                        'id', selectd_auth_method, data[3])
                    self.authMethod.set_ad_auth_ip(data[4])
                    self.authMethod.set_ad_auth_port(data[5])
                    self.authMethod.set_ad_auth_domian_name(data[6])
                    self.authMethod.save_button()

                    #判断测试点是否通过
                    self.check_with_pop_up(data, flag)

                    #清空标识状态
                    flag = False
            except Exception as e:
                print("AD auth method add fail: ") + str(e)
        self.log.log_end("addADMethod")

    u'''添加radius认证方式'''

    def add_radius_method_002(self):
        #全部认证方式
        all_auth_method = "all_globalAuthMethod"
        #已选认证方式
        selectd_auth_method = "select_globalAuthMethod"

        #日志开始记录
        self.log.log_start("addRadiusMethod")
        #获取添加系统管理员测试数据
        auth_method_data = self.get_table_data("add_auth_method")

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(auth_method_data)):
            data = auth_method_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 2:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.authMethod.select_add_meth_method(data[2])
                    self.authMethod.auth_add_button()
                    self.authMethod.check_option_is_not_exist(
                        'id', all_auth_method, data[3])
                    #校验是否添加到已选认证方式
                    self.authMethod.check_option_is_selectd(
                        'id', selectd_auth_method, data[3])
                    self.authMethod.set_radius_auth_ip(data[4])
                    self.authMethod.set_radius_auth_port(data[5])
                    self.authMethod.set_radius_auth_key(data[7])
                    self.authMethod.save_button()

                    #判断测试点是否通过
                    self.check_with_pop_up(data, flag)

                    #清空标识状态
                    flag = False
            except Exception as e:
                print("Radius auth method add fail: ") + str(e)
        self.log.log_end("addRadiusMethod")

    u'''添加AD域+口令认证方式'''

    def add_ad_and_pwd_method_003(self):
        #全部认证方式
        all_auth_method = "all_globalAuthMethod"
        #已选认证方式
        selectd_auth_method = "select_globalAuthMethod"

        #日志开始记录
        self.log.log_start("addADAndPwdMethod")
        #获取添加系统管理员测试数据
        auth_method_data = self.get_table_data("add_auth_method")

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(auth_method_data)):
            data = auth_method_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 3:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.authMethod.select_add_meth_method(data[2])
                    self.authMethod.auth_add_button()
                    self.authMethod.check_option_is_not_exist(
                        'id', all_auth_method, data[3])
                    #校验是否添加到已选认证方式
                    self.authMethod.check_option_is_selectd(
                        'id', selectd_auth_method, data[3])
                    self.authMethod.save_button()

                    #判断测试点是否通过
                    self.check_with_pop_up(data, flag)

                    #清空标识状态
                    flag = False
            except Exception as e:
                print("AdAndPwd auth method add fail: ") + str(e)
        self.log.log_end("addADAndPwdMethod")

    u'''添加radius+口令认证方式'''

    def add_radius_and_pwd_method_004(self):
        #全部认证方式
        all_auth_method = "all_globalAuthMethod"
        #已选认证方式
        selectd_auth_method = "select_globalAuthMethod"

        #日志开始记录
        self.log.log_start("addRadiusMethod")
        #获取添加系统管理员测试数据
        auth_method_data = self.get_table_data("add_auth_method")

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(auth_method_data)):
            data = auth_method_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 4:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.authMethod.select_add_meth_method(data[2])
                    self.authMethod.auth_add_button()
                    self.authMethod.check_option_is_not_exist(
                        'id', all_auth_method, data[3])
                    #校验是否添加到已选认证方式
                    self.authMethod.check_option_is_selectd(
                        'id', selectd_auth_method, data[3])
                    self.authMethod.save_button()

                    #判断测试点是否通过
                    self.check_with_pop_up(data, flag)

                    #清空标识状态
                    flag = False
            except Exception as e:
                print("RadiusAndPwd auth method add fail: ") + str(e)
        self.log.log_end("addRadiusAndPwdMethod")

    u'''添加证书认证方式'''

    def add_cert_method_005(self):
        #全部认证方式
        all_auth_method = "all_globalAuthMethod"
        #已选认证方式
        selectd_auth_method = "select_globalAuthMethod"

        #日志开始记录
        self.log.log_start("addCertMethod")
        #获取添加系统管理员测试数据
        auth_method_data = self.get_table_data("add_auth_method")

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(auth_method_data)):
            data = auth_method_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 5:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.authMethod.select_add_meth_method(data[2])
                    self.authMethod.auth_add_button()
                    self.authMethod.check_option_is_not_exist(
                        'id', all_auth_method, data[3])
                    #校验是否添加到已选认证方式
                    self.authMethod.check_option_is_selectd(
                        'id', selectd_auth_method, data[3])
                    self.authMethod.save_button()

                    #判断测试点是否通过
                    self.check_with_pop_up(data, flag)

                    #清空标识状态
                    flag = False
            except Exception as e:
                print("Cert auth method add fail: ") + str(e)
        self.log.log_end("addCertMethod")

    u'''添加所有的认证方式并校验是否添加成功'''

    def auth_method_add_is_success_006(self):
        #已选认证方式
        selectd_auth_method = "select_globalAuthMethod"

        auth_method_data = self.get_table_data("login")

        #日志开始记录
        self.log.log_start("checkout auth method whether add success")
        for dataRow in range(len(auth_method_data)):
            data = auth_method_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 1:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    auth_select_text = self.authMethod.get_select_options_text(
                        "id", selectd_auth_method)
                    self.authMethod.get_user_select_auth_text(data)
                    user_select_text = self.authMethod.get_select_options_text(
                        "id", "fortAuthenticationCode")
                    self.authMethod.compare_list_is_equal(
                        auth_select_text, user_select_text, data)
                    self.frameElem.from_frame_to_otherFrame("topFrame")
                    self.commonSuite.user_quit()
                    login_select_text = self.authMethod.get_select_options_text(
                        "id", "loginMethod")
                    self.authMethod.compare_list_is_equal(
                        auth_select_text, login_select_text, data)
            except Exception as e:
                print "is not equal" + str(e)
        self.log.log_end(
            "Add all auth method and checkout whether add success")

    #修改AD域认证配置
    def mod_ad_method_007(self):

        #日志开始记录
        self.log.log_start("ModeyADMethodConfig")
        self.commonSuite.login_secadmin()
        self.commonSuite.switch_to_moudle(u"策略配置", u"认证强度")
        time.sleep(3)
        #获取修改AD域配置测试数据
        auth_method_data = self.get_table_data("mod_ad_method")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(auth_method_data)):
            data = auth_method_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.authMethod.set_ad_auth_ip(data[2])
                    self.authMethod.set_ad_auth_port(data[3])
                    self.authMethod.set_ad_auth_domian_name(data[4])
                    self.authMethod.save_button()

                    #判断测试点是否通过
                    self.check_with_pop_up(data, flag)

                    #清空标识状态
                    flag = False
            except Exception as e:
                print("Modey AD method config fail: ") + str(e)
        self.log.log_end("ModeyADMethodConfig")

    #AD域认证配置校验
    def ad_method_checkout_008(self):

        #日志开始记录
        self.log.log_start("ADMethodCheckout")
        #获取修改AD域配置测试数据
        auth_method_data = self.get_table_data("ad_method_checkout")

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(auth_method_data)):
            data = auth_method_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.authMethod.set_ad_auth_ip(data[2])
                    self.authMethod.set_ad_auth_port(data[3])
                    self.authMethod.set_ad_auth_domian_name(data[4])
                    if dataRow == range(len(auth_method_data))[-1]:
                        self.authMethod.domian1_add_button()
                        self.authMethod.set_domian2_ip(data[5])
                    self.authMethod.save_button()

                    #判断测试点是否通过
                    self.check_with_pop_up(data, flag)

                    #清空标识状态
                    flag = False
            except Exception as e:
                print("ADMethodCheckout fail: ") + str(dataRow) + str(e)
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.authMethod.domian2_del_button()
        self.log.log_end("ADMethodCheckout")

    u'''radius认证校验'''

    def radius_checkout_009(self):

        #日志开始记录
        self.log.log_start("RadiusCheckout")
        #获取添加系统管理员测试数据
        auth_method_data = self.get_table_data(
            "radius_method_checkout")  #radius_method_checkout,Sheet1
        #radius通讯秘钥
        radius_auth_key = "radiusShareSecret0"

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(auth_method_data)):
            data = auth_method_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.authMethod.set_radius_auth_ip(data[2])
                    self.authMethod.set_radius_auth_port(data[3])
                    if data[2] == "" or data[2] == "123.abc":
                        self.getElem.find_element_with_wait(
                            'id', radius_auth_key).click()
                        self.cmf.click_login_msg_button()
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.authMethod.set_radius_auth_key(data[4])
                    self.authMethod.set_radius_auth_key(data[4])
                    self.authMethod.set_backup_radius_ip(data[5])
                    self.authMethod.set_backup_radius_key(data[6])
                    self.authMethod.save_button()

                    #判断测试点是否通过
                    self.check_with_pop_up(data, flag)

                    #清空标识状态
                    flag = False

            except Exception as e:
                print("RadiusCheckout fail: ") + str(e)
        self.log.log_end("RadiusCheckout")

    u'''删除其他认证方式'''

    def del_auth_method_010(self):
        #全部认证方式
        all_auth_method = "all_globalAuthMethod"
        #已选认证方式
        selectd_auth_method = "select_globalAuthMethod"
        #获取添加系统管理员测试数据
        auth_method_data = self.get_table_data("del_raius_method")

        #日志开始记录
        self.log.log_start("delotherMethod")
        flag = False
        for dataRow in range(len(auth_method_data)):
            data = auth_method_data[dataRow]
            try:
                #如果是第2行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.authMethod.quit_selectd_all_method()
                    selem = self.getElem.find_element_with_wait(
                        "id", selectd_auth_method)
                    self.authMethod.selectd_all_method(selem, '2', '1')
                    self.authMethod.auth_del_button()
                    #校验已选认证方式只有默认方式
                    self.authMethod.check_option_is_selectd(
                        'id', all_auth_method, data[3])
                    self.authMethod.save_button()

                    #判断测试点是否通过
                    self.check_with_pop_up(data, flag)

                #清空标识状态
                flag = False

            except Exception as e:
                print("delAuthMethod fail: ") + str(e)
        self.log.log_end("delAuthMethod")
예제 #3
0
class testLogin(object):
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.loginFun = loginPage(self.driver)
        self.cmf = commonFun(self.driver)
        self.dataFile = dataFileName()
        self.comsuit = CommonSuiteData(self.driver)

    u'''获取测试数据
    	Parameters:
    		- sheetname:sheet名称
    		return:表格数据
    '''

    def get_table_data(self, sheetname):
        filePath = self.dataFile.get_login_test_data_url()
        loginData = self.dataFile.get_data(filePath, sheetname)
        return loginData

    u'''登陆的div弹窗的xpath'''

    def login_msg(self):
        login_msg = "html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
        return login_msg

    u'''根据访问方式类型登录测试
            parameters:
                sheetname : 表单名称
    '''

    def login_type(self, sheetname):
        loginMes = self.login_msg()
        loginData = self.get_table_data(sheetname)
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(loginData)):
            #把单行的数据赋值给列表data
            data = loginData[dataRow]

            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    if sheetname == 'default':
                        self.comsuit.login_secadmin()
                        self.comsuit.switch_to_moudle(u'运维管理', u'用户')
                        self.comsuit.userElem.change_user_status_off(
                            "gyrloginad1")
                        self.comsuit.user_quit()
                        self.loginFun.login(data)
                    elif sheetname == 'ad':
                        self.loginFun.ad_login(data)
                    elif sheetname == 'pwd_ad':
                        self.loginFun.ad_pwd_login(data)
                    elif sheetname == 'radius':
                        self.loginFun.radius_pwd_login(data)

                        #如果登陆成功,点击退出
                    if self.loginFun.is_login_success():
                        self.loginFun.quit()
                        #设定没有检查点的测试项通过
                        flag = True

                    self.cmf.test_win_check_point("xpath", loginMes, data,
                                                  flag)

                    #清空标识状态
                    flag = False

            except Exception as e:
                print("User login fail: ") + str(e)

    #登陆测试
    def login(self):
        self.log.log_start("login")
        u'''可以循环设定数据测试系统登录'''
        sheets_name = ['ad', 'pwd_ad', 'radius', 'default']
        for sheetname in sheets_name:
            self.login_type(sheetname)
        self.log.log_end("login")
예제 #4
0
class testRetime(object):

	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.frameElem = frameElement(driver)
		self.command = CommandRule(driver)
		self.comsuit = CommonSuiteData(driver)
		self.timerule = TimeRule(driver)
		self.retime = RetimeRule(driver)
		self.loginElem = loginPage(driver)

	u'''提示内容框元素路径'''
	def div_msg(self):
		div_msg = "html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
		return div_msg

	u'''获取测试数据
		Parameters:
			- sheetname:sheet名称
		return:表格数据
	'''
	def get_table_data(self, sheetname):
		dataFile = dataFileName()
		retrulePath = dataFile.get_retime_test_data_url()
		retruleData = dataFile.get_data(retrulePath, sheetname)
		return retruleData

	u'''添加资源时间规则'''
	def add_retime_rule_001(self):

		#日志开始记录
		self.log.log_start("add_retime_rule")
		#获取添加资源时间规则测试数据
		retruleData = self.get_table_data("add_retime_rule")
		#保存成功的弹出框
		comrulMsg = self.div_msg()

		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(retruleData)):
			data = retruleData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.command.click_add_button()
					if dataRow == 3:
						self.retime.click_running_state()
					self.timerule.start_date(data[2])
					self.timerule.date_of_termination(data[4], data[5])
					self.retime.set_month_start_time(data[6])
					self.retime.set_month_end_time(data[7])
					self.retime.set_week_start_time(data[8])
					self.retime.set_week_end_time(data[9])
					self.retime.set_day_start_time(data[10])
					self.retime.set_day_end_time(data[11])
					self.retime.select_action(data[12])
					self.command.click_add_users_button()
					self.command.check_all_user()
					self.command.click_add_resource_button()
					self.retime.check_resource(data[13])
					self.retime.click_save_retime()
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", comrulMsg, data, flag)
					self.command.click_back_command()
			except Exception as e:
				print ("add_retime_rule fail:" + str(e))
		self.log.log_end("add_retime_rule")

	u'''编辑资源时间规则'''
	def mod_retime_rule_002(self):

		#日志开始记录
		self.log.log_start("mod_retime_rule")
		#获取编辑资源时间规则测试数据
		retruleData = self.get_table_data("mod_retime_rule")
		#保存成功的弹出框
		comrulMsg = self.div_msg()

		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(retruleData)):
			data = retruleData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.retime.click_option_method(data[2], data[3])
					self.retime.select_action(data[4])
					self.retime.click_save_retime()
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", comrulMsg, data, flag)
					self.command.click_back_command()
			except Exception as e:
				print ("mod_retime_rule fail:" + str(e))

		self.log.log_end("mod_retime_rule")

	u'''资源时间规则结果'''
	def add_retime_rule_result_003(self):

		#日志开始记录
		self.log.log_start("add_retime_rule_result")
		#获取资源时间审批测试数据
		retruleData = self.get_table_data("add_retime_rule_result")
		for dataRow in range(len(retruleData)):
			data = retruleData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					if dataRow == 1:
						self.comsuit.user_quit()
						self.loginElem.login(data)
						self.frameElem.from_frame_to_otherFrame("topFrame")
						self.cmf.select_role_by_text(u"运维操作员")
					self.retime.check_resource_time_rule(data)
			except Exception as e:
				print ("add_retime_rule_result fail:" + str(e))

		self.comsuit.user_quit()
		self.log.log_end("add_retime_rule_result")

	u'''操作资源时间规则'''
	def option_retime_rule_004(self):
		self.comsuit.login_secadmin()
		self.comsuit.switch_to_moudle(u"运维管理", u"规则定义")
		self.command.click_left_rule(3)

		#日志开始记录
		self.log.log_start("option_retime_rule")
		#获取操作资源时间规则测试数据
		retruleData = self.get_table_data("option_retime_rule")
		#保存成功的弹出框
		comrulMsg = self.div_msg()

		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(retruleData)):
			data = retruleData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					if dataRow == 1:
						self.retime.click_bulkdel_retime()
					elif dataRow == 2 or dataRow == 3:
						self.retime.click_option_method(data[2], data[3])
					elif dataRow == 4 or dataRow == 5:
						time.sleep(5)
						self.retime.click_option_method(data[2], data[3])
						self.command.set_row_command(data[4])
						self.command.check_sure_button()
						self.frameElem.switch_to_content()
						self.cmf.test_win_check_point("xpath", comrulMsg, data, flag)
						time.sleep(3)
						self.command.click_cancel_button()
						continue
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", comrulMsg, data, flag)
			except Exception as e:
				print ("option_retime_rule fail:" + str(e))

		self.log.log_end("option_retime_rule")

	u'''校验资源时间规则'''
	def check_retime_rule_005(self):

		#日志开始记录
		self.log.log_start("check_retime_rule")
		#获取校验资源时间规则测试数据
		retruleData = self.get_table_data("check_retime_rule")
		#保存成功的弹出框
		comrulMsg = self.div_msg()
		self.command.click_add_button()
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(retruleData)):
			data = retruleData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					if 2 <= dataRow <= 4:
						if dataRow != 4:
							self.timerule.start_date(data[2], data[3])
						else:
							self.timerule.start_date(data[2])
						if dataRow != 2:
							self.timerule.date_of_termination(data[4], data[5])
					elif 5 <= dataRow <= 11:
						if dataRow == 5:
							self.timerule.date_of_termination(data[4], data[5])
						self.retime.set_month_start_time(data[6])
						self.retime.set_month_end_time(data[7])
						if dataRow == 11:
							self.retime.set_day_start_time(data[8])
					elif 12 <= dataRow <= 17:
						self.retime.set_day_start_time(data[8])
						self.retime.set_day_end_time(data[9])
					elif dataRow == 18:
						self.command.click_add_users_button()
						self.command.check_all_user()
					self.retime.click_save_retime()
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", comrulMsg, data, flag)
			except Exception as e:
				print ("check_retime_rule fail:" + str(e))

		self.command.click_back_command()
		self.log.log_end("check_retime_rule")

	u'''删除资源时间规则'''
	def del_retime_rule_006(self):
		#日志开始记录
		self.log.log_start("del_retime_rule")
		#获取删除资源时间规则测试数据
		retruleData = self.get_table_data("del_retime_rule")
		#保存成功的弹出框
		comrulMsg = self.div_msg()

		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(retruleData)):
			data = retruleData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.retime.click_option_method(data[2], data[3])
					self.retime.click_bulkdel_retime()
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", comrulMsg, data, flag)
					self.cmf.click_login_msg_button()
			except Exception as e:
				print ("del_retime_rule fail:" + str(e))
		self.log.log_end("del_retime_rule")