Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 def __init__(self, driver):
     self.driver = driver
     self.log = log()
     self.cmf = commonFun(driver)
     self.frameElem = frameElement(driver)
     self.testrole = testRole(driver)
     self.command = CommandRule(driver)
     self.comsuit = CommonSuiteData(driver)
     self.timerule = TimeRule(driver)
     self.retime = RetimeRule(driver)
Ejemplo n.º 3
0
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.frameElem = frameElement(driver)
		self.testrole = testRole(driver)
		self.command = CommandRule(driver)
		self.comsuit = CommonSuiteData(driver)
		self.timerule = TimeRule(driver)
		self.getElem = getElement(driver)
		self.loginElem = loginPage(self.driver)
Ejemplo n.º 4
0
class testAddress(object):
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.cmf = commonFun(driver)
        self.frameElem = frameElement(driver)
        self.testrole = testRole(driver)
        self.command = CommandRule(driver)
        self.comsuit = CommonSuiteData(driver)
        self.timerule = TimeRule(driver)
        self.getElem = getElement(driver)
        self.loginElem = loginPage(driver)
        self.adrerule = AddressRule(driver)

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

    def get_table_data(self, sheetname):
        dataFile = dataFileName()
        adrerulePath = dataFile.get_adrerule_test_data_url()
        adreruleData = dataFile.get_data(adrerulePath, sheetname)
        return adreruleData

    u'''添加地址规则'''

    def add_address_rule_001(self):

        #日志开始记录
        self.log.log_start("add_address_rule")
        #获取添加地址规则测试数据
        adreruleData = self.get_table_data("add_address_rule")
        #保存成功的弹出框
        comrulMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(adreruleData)):
            data = adreruleData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.command.click_add_button()
                    self.adrerule.set_rulename((data[2]))
                    self.timerule.select_depart(data[3])
                    self.timerule.set_status_type(data[4])
                    self.adrerule.checkbox_ip_rule(data[5])
                    self.adrerule.set_ip(data[6])
                    self.adrerule.set_ip_mask(data[7])
                    if dataRow != 1 and dataRow != 5:
                        if dataRow == 3 or dataRow == 7:
                            self.adrerule.click_add_ip_segment()
                        self.adrerule.set_ip_start(data[9])
                        self.adrerule.set_ip_end(data[10])
                    else:
                        self.adrerule.set_ip_test(data[8])
                        self.adrerule.click_test()
                        self.cmf.click_msg_button(1)
                    self.adrerule.set_description(data[11])
                    self.adrerule.click_save()
                    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.adrerule.edit_user_address_rule(data[12], data[13])
                    self.comsuit.switch_to_moudle(u'运维管理', u'规则定义')
                    self.command.click_left_rule(2)
            except Exception as e:
                print("add_address_rule fail:" + str(e))
        self.comsuit.user_quit()
        self.log.log_end("add_address_rule")

    u'''添加地址规则结果'''

    def add_address_rule_result_002(self):

        #日志开始记录
        self.log.log_start("add_address_rule_result")
        #获取添加地址规则测试数据
        adreruleData = self.get_table_data("add_address_rule")
        #保存成功的弹出框
        comrulMsg = self.testrole.popup()

        for dataRow in range(len(adreruleData)):
            data = adreruleData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    list = [data[14], data[15], data[16], data[17], data[18]]
                    self.loginElem.login(list)
                    self.frameElem.from_frame_to_otherFrame("topFrame")
                    if self.getElem.is_element_exsit('id', "logout"):
                        self.comsuit.user_quit()
                    flag = True
                    self.cmf.test_win_check_point("xpath", comrulMsg, list,
                                                  flag)
            except Exception as e:
                print("add_address_rule_result fail:" + str(e))
        self.comsuit.login_and_switch_to_dep()
        self.comsuit.switch_to_moudle(u'运维管理', u'规则定义')
        self.command.click_left_rule(2)
        self.log.log_end("add_address_rule_result")

    u'''编辑地址规则'''

    def mod_address_rule_003(self):
        #日志开始记录
        self.log.log_start("mod_address_rule")
        #获取编辑地址规则测试数据
        adreruleData = self.get_table_data("mod_address_rule")
        #保存成功的弹出框
        comrulMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(adreruleData)):
            data = adreruleData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.adrerule.click_edit_address(data[2])
                    self.adrerule.set_rulename((data[3]))
                    self.timerule.set_status_type(data[4])
                    self.adrerule.checkbox_ip_rule(data[5])
                    self.adrerule.set_ip(data[6])
                    self.adrerule.set_ip_mask(data[7])
                    self.adrerule.set_ip_start(data[8])
                    self.adrerule.set_ip_end(data[9])
                    self.adrerule.set_description(data[10])
                    self.adrerule.click_save()
                    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_address_rule fail:" + str(e))
        self.log.log_end("mod_address_rule")

    u'''校验地址规则'''

    def check_address_rule_004(self):
        #日志开始记录
        self.log.log_start("check_address_rule")
        #获取校验地址规则测试数据
        adreruleData = self.get_table_data("check_address_rule")
        #保存成功的弹出框
        comrulMsg = self.testrole.popup()
        self.command.click_add_button()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(adreruleData)):
            data = adreruleData[dataRow]
            try:
                if dataRow != 0:
                    #如果不是第一行标题,则读取数据
                    if dataRow == 2:
                        self.adrerule.checkbox_ip_rule(data[3])
                    elif dataRow == 3 or dataRow == 4:
                        self.adrerule.set_ip(data[4])
                    elif dataRow == 5:
                        self.adrerule.set_ip_mask(data[5])
                    elif dataRow != 1:
                        self.adrerule.set_rulename(data[2])
                    self.adrerule.click_save()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", comrulMsg, data,
                                                  flag)
            except Exception as e:
                print("check_address_rule fail:" + str(e))
        self.command.click_back_command()
        self.log.log_end("check_address_rule")

    u'''检索地址规则'''

    def query_address_rule_005(self):
        #日志开始记录
        self.log.log_start("query_address_rule")
        #获取检索地址规则测试数据
        adreruleData = self.get_table_data("query_address_rule")

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

    u'''删除地址规则'''

    def del_address_rule_006(self):
        #日志开始记录
        self.log.log_start("del_address_rule")
        #获取删除地址规则测试数据
        adrerulData = self.get_table_data("del_address_rule")
        #保存成功的弹出框
        comrulMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(adrerulData)):
            data = adrerulData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    if dataRow == 1:
                        self.adrerule.click_bulkdel_address()
                    else:
                        self.adrerule.click_del_address(data[2])
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", comrulMsg, data,
                                                  flag)

                    if dataRow != 1:
                        self.cmf.click_login_msg_button()

            except Exception as e:
                print("del_address_rule fail:" + str(e))
        self.log.log_end("del_address_rule")
Ejemplo n.º 5
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")
Ejemplo n.º 6
0
class testTime(object):

	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.frameElem = frameElement(driver)
		self.testrole = testRole(driver)
		self.command = CommandRule(driver)
		self.comsuit = CommonSuiteData(driver)
		self.timerule = TimeRule(driver)
		self.getElem = getElement(driver)
		self.loginElem = loginPage(self.driver)

	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.testrole.popup()

		#无检查点的测试项标识,如果为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.testrole.popup()

		#无检查点的测试项标识,如果为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_and_switch_to_dep()
		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.testrole.popup()

		#无检查点的测试项标识,如果为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.testrole.popup()
		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.testrole.popup()

		#无检查点的测试项标识,如果为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")
Ejemplo n.º 7
0
class testRetime(object):
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.cmf = commonFun(driver)
        self.frameElem = frameElement(driver)
        self.testrole = testRole(driver)
        self.command = CommandRule(driver)
        self.comsuit = CommonSuiteData(driver)
        self.timerule = TimeRule(driver)
        self.retime = RetimeRule(driver)

    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.testrole.popup()

        #无检查点的测试项标识,如果为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.testrole.popup()

        #无检查点的测试项标识,如果为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.frameElem.from_frame_to_otherFrame("topFrame")
        self.cmf.select_role_by_text(u"运维操作员")
        #日志开始记录
        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:
                    self.retime.check_resource_time_rule(data)
            except Exception as e:
                print("add_retime_rule_result fail:" + str(e))
        self.log.log_end("add_retime_rule_result")

    u'''操作资源时间规则'''

    def option_retime_rule_004(self):
        self.comsuit.sys_switch_to_dep()
        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.testrole.popup()

        #无检查点的测试项标识,如果为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.testrole.popup()
        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.testrole.popup()

        #无检查点的测试项标识,如果为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")