class testCommand(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.sso = testSso(driver) self.comsuit = CommonSuiteData(driver) u'''获取测试数据 Parameters: - sheetname:sheet名称 return:表格数据 ''' def get_table_data(self, sheetname): dataFile = dataFileName() comrulPath = dataFile.get_command_test_data_url() comrulData = dataFile.get_data(comrulPath, sheetname) return comrulData u'''添加命令规则''' def add_command_rule_001(self): #日志开始记录 self.log.log_start("add_command_rule") #获取添加命令规则测试数据 comrulData = self.get_table_data("add_command_rule") #保存成功的弹出框 comrulMsg = self.testrole.popup() #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.command.click_add_button() self.command.select_command_type((data[2])) self.command.set_command(data[3]) self.command.click_add_command_button() self.command.set_test_command(data[4]) self.command.click_test_command_button() self.cmf.click_login_msg_button() if int(data[2]) == 2: self.command.click_approver_command() self.command.check_all_user() self.command.click_add_users_button() self.command.check_all_user() self.command.click_add_resource_button() self.command.check_all_resource() self.command.click_save_command() 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_command_rule fail:" + str(e)) self.log.log_end("add_command_rule") u'''编辑命令规则''' def mod_command_rule_002(self): #日志开始记录 self.log.log_start("mod_command_rule") #获取编辑命令规则测试数据 comrulData = self.get_table_data("mod_command_rule") #保存成功的弹出框 comrulMsg = self.testrole.popup() #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.command.click_action_public_command(data[2], data[3]) self.command.set_command(data[4]) self.command.click_add_command_button() self.command.click_save_command() 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_command_rule fail:" + str(e)) self.log.log_end("mod_command_rule") u'''操作命令规则''' def option_command_rule_003(self): #日志开始记录 self.log.log_start("option_command_rule") #获取操作命令规则测试数据 comrulData = self.get_table_data("option_command_rule") #保存成功的弹出框 comrulMsg = self.testrole.popup() #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: if dataRow == 1: self.command.click_del_command() elif dataRow == 2: self.command.click_deploy_command() elif dataRow == 3 or dataRow == 4: self.command.click_action_public_command(data[2], data[3]) elif dataRow == 5 or dataRow == 6: time.sleep(5) self.command.click_action_public_command(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_command_rule fail:" + str(e)) self.log.log_end("option_command_rule") u'''校验命令规则''' def check_command_rule_004(self): #日志开始记录 self.log.log_start("check_command_rule") #获取校验命令规则测试数据 comrulData = self.get_table_data("check_command_rule") #保存成功的弹出框 comrulMsg = self.testrole.popup() self.command.click_add_button() #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: if data[2] != "no": self.command.select_command_type((data[2])) if data[3] != "no": self.command.set_command(data[3]) self.command.click_add_command_button() if data[4] != "no": self.command.set_test_command(data[4]) self.command.click_test_command_button() if dataRow == 4: self.command.click_save_command() elif dataRow == 5: self.command.click_add_users_button() self.command.check_all_user() self.command.click_save_command() elif dataRow == 6: self.command.click_add_resource_button() self.command.check_all_resource() self.command.click_save_command() elif dataRow == 7: self.command.click_approver_command() self.command.check_all_user() self.command.clear_command() self.command.click_save_command() self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", comrulMsg, data, flag) except Exception as e: print ("check_command_rule fail:" + str(e)) self.command.click_back_command() self.log.log_end("check_command_rule") u'''命令审批''' def command_approval_005(self): self.frameElem.from_frame_to_otherFrame("topFrame") self.cmf.select_role_by_text(u"运维操作员") #日志开始记录 self.log.log_start("command_approval") #获取命令审批测试数据 comrulData = self.get_table_data("command_approval") for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.command.sso_command(data) handles = self.driver.window_handles if dataRow == 2: self.command.command_by_message_approval(data[6], data[7], data[8]) self.cmf.click_login_msg_button() self.driver.switch_to.window(handles[1]) self.driver.close() self.driver.switch_to.window(handles[0]) #关闭浏览器 self.log.log_detail(data[0], True) except Exception as e: print ("command_approval fail:" + str(e)) self.log.log_end("command_approval") u'''删除命令规则''' def del_command_rule_006(self): # self.comsuit.sys_switch_to_dep() # self.comsuit.switch_to_moudle(u"运维管理", u"规则定义") #日志开始记录 self.log.log_start("del_command_rule") #获取删除命令规则测试数据 comrulData = self.get_table_data("del_command_rule") #保存成功的弹出框 comrulMsg = self.testrole.popup() #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.command.click_action_public_command(data[2], data[3]) self.command.click_del_command() 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_command_rule fail:" + str(e)) self.log.log_end("del_command_rule")
class testCommand(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.sso = testSso(driver) self.comsuit = CommonSuiteData(driver) u'''获取测试数据 Parameters: - sheetname:sheet名称 return:表格数据 ''' def get_table_data(self, sheetname): dataFile = dataFileName() comrulPath = dataFile.get_command_test_data_url() comrulData = dataFile.get_data(comrulPath, sheetname) return comrulData u'''添加命令规则''' def add_command_rule_001(self): #日志开始记录 self.log.log_start("add_command_rule") #获取添加命令规则测试数据 comrulData = self.get_table_data("add_command_rule") #保存成功的弹出框 comrulMsg = self.testrole.popup() #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.command.click_add_button() self.command.select_command_type((data[2])) self.command.set_command(data[3]) self.command.click_add_command_button() self.command.set_test_command(data[4]) self.command.click_test_command_button() self.cmf.click_login_msg_button() if int(data[2]) == 2: self.command.click_approver_command() self.command.check_all_user() self.command.click_add_users_button() self.command.check_all_user() self.command.click_add_resource_button() self.command.check_all_resource() self.command.click_save_command() 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_command_rule fail:" + str(e)) self.log.log_end("add_command_rule") u'''编辑命令规则''' def mod_command_rule_002(self): #日志开始记录 self.log.log_start("mod_command_rule") #获取编辑命令规则测试数据 comrulData = self.get_table_data("mod_command_rule") #保存成功的弹出框 comrulMsg = self.testrole.popup() #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.command.click_action_public_command(data[2], data[3]) self.command.set_command(data[4]) self.command.click_add_command_button() self.command.click_save_command() 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_command_rule fail:" + str(e)) self.log.log_end("mod_command_rule") u'''操作命令规则''' def option_command_rule_003(self): #日志开始记录 self.log.log_start("option_command_rule") #获取操作命令规则测试数据 comrulData = self.get_table_data("option_command_rule") #保存成功的弹出框 comrulMsg = self.testrole.popup() #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: if dataRow == 1: self.command.click_del_command() elif dataRow == 2: self.command.click_deploy_command() elif dataRow == 3 or dataRow == 4: self.command.click_action_public_command( data[2], data[3]) elif dataRow == 5 or dataRow == 6: time.sleep(5) self.command.click_action_public_command( 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_command_rule fail:" + str(e)) self.log.log_end("option_command_rule") u'''校验命令规则''' def check_command_rule_004(self): #日志开始记录 self.log.log_start("check_command_rule") #获取校验命令规则测试数据 comrulData = self.get_table_data("check_command_rule") #保存成功的弹出框 comrulMsg = self.testrole.popup() self.command.click_add_button() #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: if data[2] != "no": self.command.select_command_type((data[2])) if data[3] != "no": self.command.set_command(data[3]) self.command.click_add_command_button() if data[4] != "no": self.command.set_test_command(data[4]) self.command.click_test_command_button() if dataRow == 4: self.command.click_save_command() elif dataRow == 5: self.command.click_add_users_button() self.command.check_all_user() self.command.click_save_command() elif dataRow == 6: self.command.click_add_resource_button() self.command.check_all_resource() self.command.click_save_command() elif dataRow == 7: self.command.click_approver_command() self.command.check_all_user() self.command.clear_command() self.command.click_save_command() self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", comrulMsg, data, flag) except Exception as e: print("check_command_rule fail:" + str(e)) self.command.click_back_command() self.log.log_end("check_command_rule") u'''命令审批''' def command_approval_005(self): self.frameElem.from_frame_to_otherFrame("topFrame") self.cmf.select_role_by_text(u"运维操作员") #日志开始记录 self.log.log_start("command_approval") #获取命令审批测试数据 comrulData = self.get_table_data("command_approval") for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.command.sso_command(data) handles = self.driver.window_handles if dataRow == 2: self.command.command_by_message_approval( data[6], data[7], data[8]) self.cmf.click_login_msg_button() self.driver.switch_to.window(handles[1]) self.driver.close() self.driver.switch_to.window(handles[0]) #关闭浏览器 self.log.log_detail(data[0], True) except Exception as e: print("command_approval fail:" + str(e)) self.log.log_end("command_approval") u'''删除命令规则''' def del_command_rule_006(self): # self.comsuit.sys_switch_to_dep() # self.comsuit.switch_to_moudle(u"运维管理", u"规则定义") #日志开始记录 self.log.log_start("del_command_rule") #获取删除命令规则测试数据 comrulData = self.get_table_data("del_command_rule") #保存成功的弹出框 comrulMsg = self.testrole.popup() #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(comrulData)): data = comrulData[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0: self.command.click_action_public_command(data[2], data[3]) self.command.click_del_command() 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_command_rule fail:" + str(e)) self.log.log_end("del_command_rule")
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")