コード例 #1
0
ファイル: test_user.py プロジェクト: isomper/testIsomp
class User():
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.user = UserPage(driver)
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
		self.tableEle = tableElement(self.driver)

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

	u'''获取测试数据
		Parameters:
			- sheetname:sheet名称
			return:表格数据
	'''
	def get_table_data(self,sheetname):
		dataFile = dataFileName()
		filePath = dataFile.get_person_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):
		
		#点击保存按钮弹出框
		user_msg = self.user_msg()	
		self.frameElem.switch_to_content()
		self.cmf.test_win_check_point("xpath",user_msg,data,flag)
		
	u'''校验没有弹出框类型用例是否通过
			parameters: 
				data : 检查点
				flag : 通过标识(True lse)
				status : 0,代表判断条件为相等
	'''
	def check_without_pop_up(self,var1,var2,data):
		#点击保存按钮弹出框
		user_msg = self.user_msg()
		if var1 == var2:
			self.cmf.test_win_check_point("","",data,True)
		else:
			self.cmf.test_win_check_point("","",data,False)		

	u'''重置'''	
	def reset(self):
		self.user.click_reset_button()
		self.user.click_search_button()
	
	u'''切换至用户模块'''
	def switch_to_user_module(self):
		self.frameElem.switch_to_content()
		self.frameElem.switch_to_top()
		self.cmf.select_menu(u"运维管理")
		self.cmf.select_menu(u"运维管理",u"用户")	

	u'''添加用户'''
	def add_user_001(self):
		#日志开始记录
		self.log.log_start("addUser")
		#获取添加用户的数据
		user_data = self.get_table_data("add_user")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.user.add_button()
					self.user.set_user_account(data[2])
					self.user.set_user_name(data[3])
					if data[6] != "":
						self.user.set_dep(data[6])
					self.user.set_user_pwd(data[7])
					self.user.set_user_enquire_pwd(data[8])
					self.user.set_user_role(data[15])
					self.user.click_role_add_button()
					self.user.save_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)
					
					#清空标识状态
					flag = False
#					self.switch_to_user_module()
#					self.cmf.back()
					self.user.click_back_button()
					if self.cmf.is_namevalue_exsit(data[2],"fortUserAccount"):
						print ("add user success")
			except Exception as e:
				print ("user add fail: ") + str(e)
		self.log.log_end("addUser")

	u'''编辑用户'''
	def edit_user_002(self):

		#日志开始记录
		self.log.log_start("editUser")
		#获取编辑用户的数据
		user_data = self.get_table_data("mod_user")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:

					self.frameElem.from_frame_to_otherFrame("mainFrame")

					self.user.operate_edit(data[2])
					self.user.set_user_account(data[3])
					self.user.set_user_name(data[4])
					self.user.set_user_status(data[8])
					self.user.set_user_pwd(data[9])
					self.user.set_user_enquire_pwd(data[10])               
					self.user.save_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)

					#清空标识状态
					flag = False
					self.switch_to_user_module()
#					self.cmf.back()
#					self.user.click_back_button()
					if self.cmf.is_namevalue_exsit(data[2],"fortUserAccount"):
						print ("edit user success")
			except Exception as e:
				print ("edit user fail: ") + str(e)
		self.log.log_end("editUser")	

	u'''生成证书'''
	def create_user_cert_003(self):
		
		#日志开始记录
		self.log.log_start("CreateUserCert")
		#获取生成证书用户的数据
		user_data = self.get_table_data("create_cert")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.user.operate_cert(data[3])
					self.user.create_cert()
					cert_name = self.user.get_cert()
					
					#判断生成的证书名字和指定的名字是否相等
					self.check_without_pop_up(cert_name,data[2],data)
						
					#清空标识状态
					flag = False
					self.switch_to_user_module()
#					self.cmf.back()
			except Exception as e:
				print ("Create user cert fail: ") + str(e)
		self.log.log_end("CreateUserCert")

	u'''重新生成证书'''
	def create_user_cert_again_003(self):
		#点击保存按钮弹出框
		user_msg = self.user_msg()
		
		#日志开始记录
		self.log.log_start("ReCreateUserCert")
		#获取重新生成证书的数据
		user_data = self.get_table_data("reCreate_cert")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.user.operate_cert(data[2])
					cert_num_old = self.user.get_cert_serial_num()

					self.user.create_cert()
					self.cmf.click_login_msg_button()
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					cert_num_new = self.user.get_cert_serial_num()

					if cert_num_old != cert_num_new:
						self.cmf.test_win_check_point("","",data,True)
					else:
						self.cmf.test_win_check_point("","",data,False)
					

					#清空标识状态
					flag = False
					self.switch_to_user_module()
#					self.cmf.back()
			except Exception as e:
				print ("ReCreate user cert fail: ") + str(e)
		self.log.log_end("ReCreateUserCert")

	u'''删除证书'''
	def delete_user_cert_004(self):

		#日志开始记录
		self.log.log_start("DeleteUserCert")
		#获取删除证书的数据
		user_data = self.get_table_data("delete_cert")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.user.operate_cert(data[3])
					self.user.delete_cert()

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

					self.frameElem.from_frame_to_otherFrame("mainFrame")
					if self.user.get_init_cert_name() == data[2]:
						print ("Delete cert success!")						
					#清空标识状态
					flag = False
					self.frameElem.from_frame_to_otherFrame("mainFrame")
#					self.switch_to_user_module()
					self.cmf.back()
			except Exception as e:
				print ("Delete user cert fail: ") + str(e)
		self.log.log_end("DeleteUserCert")

	u'''校验用户'''
	def checkout_user_005(self):
		#保存成功的弹出框
		user_msg = self.user_msg()
		#日志开始记录
		self.log.log_start("checkoutUser")
		#获取用户校验的数据
		user_data = self.get_table_data("user_check")#user_check
		#无检查点的测试项标识,如果为True说明通过
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		self.user.add_button()		
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.user.set_user_account(data[2])
					self.user.set_user_name(data[3])
					if dataRow == range(len(user_data))[-1]:
						self.user.clear_dep()				
					self.user.set_user_pwd(data[7])
					self.user.set_user_enquire_pwd(data[8])
					self.user.set_user_mobile(data[9])
					self.user.set_user_phone(data[10])
					self.user.set_user_email(data[11])            
					self.user.save_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)

					#清空标识状态
					flag = False
			except Exception as e:
				print ("checkoutUser fail: ") + str(e)
		self.switch_to_user_module()
		self.log.log_end("checkoutUser")

	u'''检索条件:用户状态'''
	def search_user_by_status_006(self):

		#日志开始记录
		self.log.log_start("Search user by status")
		#获取按照用户状态检索的数据
		user_data = self.get_table_data("search_by_status")#user_check
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					row = self.user.search_by_status(data[3])
					self.user.search_by_user_status(data[2])
					self.user.click_search_button()
					search_row = self.user.get_rows()
					
					#判断测试项是否通过
					self.check_without_pop_up(row,search_row,data)
					self.reset()
					#清空标识状态
					flag = False			
			except Exception as e:
				print ("search user by status fail: ") + str(e)
		
		self.log.log_end("Search user by status")

	u'''检索条件:账号或者名称'''
	def search_user_by_username_006(self):

		#日志开始记录
		self.log.log_start("Search user by username")
		#获取按照账号或名称检索的数据
		user_data = self.get_table_data("search_by_name")#user_check
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					row = self.user.search_direct_by_account_or_name(data[3])
					self.user.search_accountorname(data[3])
					self.user.click_search_button()
					search_row = self.user.get_rows()
					
					#判断测试项是否通过
					self.check_without_pop_up(row,search_row,data)
					self.reset()

					#清空标识状态
					flag = False			
			except Exception as e:
				print ("search user by username fail: ") + str(e)
		
		self.log.log_end("Search user by username")
	

	u'''检索条件:部门'''
	def search_user_by_dep_006(self):

		#日志开始记录
		self.log.log_start("Search user by department")
		#获取按部门检索的数据
		user_data = self.get_table_data("search_by_dep")#user_check
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					if dataRow == 1:
						row = self.user.search_direct_by_dep(data[3])
						self.user.set_dep(data[3])
					elif dataRow == 2:
						row = self.user.get_rows()
						self.user.click_child_node()
						self.user.set_dep(data[3])
					
					self.user.click_search_button()
					search_row = self.user.get_rows()
					
					#判断测试项是否通过
					self.check_without_pop_up(row,search_row,data)
					self.reset()
					#清空标识状态
					flag = False		
			except Exception as e:
				print ("search user by department fail: ") + str(e)
		
		self.log.log_end("Search user by department")

	u'''检索条件:角色'''
	def search_user_by_role_006(self):

		#日志开始记录
		self.log.log_start("SearchUserByRole")
		#获取按角色检索的数据
		user_data = self.get_table_data("search_by_role")#user_check
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					row = self.user.search_direct_by_role(data[3])
					self.user.search_user_role(data[3])
					self.user.click_search_button()
					search_row = self.user.get_rows()
					#判断测试项是否通过
					self.check_without_pop_up(row,search_row,data)
					self.reset()
					#清空标识状态
					flag = False	
			except Exception as e:
				print ("search user by role fail: ") + str(e)
		
		self.log.log_end("SearchUserByRole")
	

	u'''删除单个用户'''
	def del_user_007(self):

		#日志开始记录
		self.log.log_start("DelOneUser")
		#获取删除用户(单个)的数据
		user_data = self.get_table_data("del_user")#user_check
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.user.operate_delete(data[2])
					self.cmf.click_login_msg_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)
					
					#清空标识状态
					flag = False
					
					#判断删除的账号是否存在
					if not self.cmf.is_namevalue_exsit(data[2],"fortUserAccount"):
						print ("del user success")					
			except Exception as e:
				print ("DelOneUser fail: ") + str(e)
		self.log.log_end("DelOneUser")
	
	

	u'''删除全部用户'''
	def del_all_user_008(self):

		#日志开始记录
		self.log.log_start("DelAllUser")
		#获取用户删除的数据
		user_data = self.get_table_data("del_all_user")#user_check
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
#					self.frameElem.from_frame_to_otherFrame("mainFrame")
#					self.user.page_select_all()
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.user.del_specified_user(data[2])
					#self.user.select_all_button()
					self.user.del_button()
					self.cmf.click_login_msg_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)
					
					#清空标识状态
					flag = False
				
			except Exception as e:
				print ("del all fail: ") + str(e)
		self.log.log_end("DelAllUser")
	

#if __name__ == "__main__":#internet explorer
#	browser = setDriver().set_local_driver()
#	commonSuite = CommonSuiteData(browser)
#	userCase = User(browser)
#	commonSuite.isomper_login()
#	cmf = commonFun(browser)
#
#	#添加角色
#	commonSuite.add_sys_role()
##	commonSuite.add_dep_role()
#	cmf.select_menu(u'运维管理')
#	cmf.select_menu(u'运维管理','用户')
	
#	userCase.add_user_001()
#	userCase.edit_user_002()
#	userCase.create_user_cert_003()
#	userCase.create_user_cert_again_003()
#	userCase.delete_user_cert_004()
#
#	userCase.checkout_user_005()
#	userCase.search_user_by_username_006()
#	userCase.search_user_by_status_006()
#	userCase.search_user_by_dep_006()
#	userCase.search_user_by_role_006()
#	userCase.del_user_007()
#	userCase.del_all_user_008()
コード例 #2
0
class testSystemLog():
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.cmf = commonFun(driver)
        self.getElem = getElement(driver)
        self.cnEnde = cnEncode()
        self.userElem = UserPage(driver)
        self.systemLog = SystemLogPage(self.driver)
        self.tableElem = tableElement(self.driver)
        self.selectElem = selectElement(driver)
        self.dataFile = dataFileName()
        self.frameElem = frameElement(self.driver)
        self.loginFun = loginPage(self.driver)
        self.commonSuite = CommonSuiteData(self.driver)

    u'''校验没有弹出框类型用例是否通过
			parameters: 
				data : 检查点
				count :正确的行数
	'''

    def check_without_pop_up(self, count, data):
        #获取行数
        table_count = str(self.systemLog.get_table_count())
        if count == table_count:
            self.cmf.test_win_check_point("", "", data, True)
        else:
            self.cmf.test_win_check_point("", "", data, False)

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

    def get_table_data(self, sheetname):
        dataFile = dataFileName()
        filePath = dataFile.get_system_log_test_url()
        queryData = dataFile.get_data(filePath, sheetname)
        return queryData

    u'''配置审计检索功能'''

    def system_log_query_001(self):  #query_type
        #日志开始记录
        self.log.log_start("SystemLogQuery_001")
        #获取配置审计检索的数据
        ad_data = self.get_table_data("system_log_query")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(ad_data)):
            data = ad_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.systemLog.select_date(data[2])
                    if data[4] != "":
                        self.userElem.set_dep(data[4])
                        #data[4]代表是否勾选子节点(no代表不勾选)
                        if data[3] != "no":
                            self.userElem.click_child_node()
                    self.systemLog.select_system_log_type(data[5])
                    self.systemLog.click_query()
                    #判断测试项是否通过
                    self.check_without_pop_up(data[6], data)
                    #清空标识状态
                    flag = False
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.userElem.click_reset_button()
            except Exception as e:
                print("System Log query fail: ") + str(e)
        self.log.log_end("SystemLogQuery_001")
コード例 #3
0
ファイル: test_user.py プロジェクト: isomper/testIsompty
class User():
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.user = UserPage(driver)
        self.cmf = commonFun(driver)
        self.getElem = getElement(driver)
        self.cnEnde = cnEncode()
        self.selectElem = selectElement(driver)
        self.dataFile = dataFileName()
        self.frameElem = frameElement(self.driver)
        self.tableEle = tableElement(self.driver)

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

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

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

    def get_table_data(self, sheetname):
        dataFile = dataFileName()
        filePath = dataFile.get_person_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):

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

    u'''校验没有弹出框类型用例是否通过
			parameters: 
				data : 检查点
				flag : 通过标识(True lse)
				status : 0,代表判断条件为相等
	'''

    def check_without_pop_up(self, var1, var2, data):
        #点击保存按钮弹出框
        user_msg = self.user_msg()
        if var1 == var2:
            self.cmf.test_win_check_point("", "", data, True)
        else:
            self.cmf.test_win_check_point("", "", data, False)

    u'''重置'''

    def reset(self):
        self.user.click_reset_button()
        self.user.click_search_button()

    u'''切换至用户模块'''

    def switch_to_user_module(self):
        self.frameElem.switch_to_content()
        self.frameElem.switch_to_top()
        self.cmf.select_menu(u"运维管理")
        self.cmf.select_menu(u"运维管理", u"用户")

    u'''添加用户'''

    def add_user_001(self):
        #日志开始记录
        self.log.log_start("addUser")
        #获取添加用户的数据
        user_data = self.get_table_data("add_user")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.user.add_button()
                    self.user.set_user_account(data[2])
                    self.user.set_user_name(data[3])
                    if data[6] != "":
                        self.user.set_dep(data[6])
                    self.user.set_user_pwd(data[7])
                    self.user.set_user_enquire_pwd(data[8])
                    self.user.set_user_role(data[15])
                    self.user.click_role_add_button()
                    self.user.save_button()

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

                    #清空标识状态
                    flag = False
                    #					self.switch_to_user_module()
                    #					self.cmf.back()
                    self.user.click_back_button()
                    if self.cmf.is_namevalue_exsit(data[2], "fortUserAccount"):
                        print("add user success")
            except Exception as e:
                print("user add fail: ") + str(e)
        self.log.log_end("addUser")

    u'''编辑用户'''

    def edit_user_002(self):

        #日志开始记录
        self.log.log_start("editUser")
        #获取编辑用户的数据
        user_data = self.get_table_data("mod_user")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:

                    self.frameElem.from_frame_to_otherFrame("mainFrame")

                    self.user.operate_edit(data[2])
                    self.user.set_user_account(data[3])
                    self.user.set_user_name(data[4])
                    self.user.set_user_status(data[8])
                    self.user.set_user_pwd(data[9])
                    self.user.set_user_enquire_pwd(data[10])
                    self.user.save_button()

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

                    #清空标识状态
                    flag = False
                    self.switch_to_user_module()
                    #					self.cmf.back()
                    #					self.user.click_back_button()
                    if self.cmf.is_namevalue_exsit(data[2], "fortUserAccount"):
                        print("edit user success")
            except Exception as e:
                print("edit user fail: ") + str(e)
        self.log.log_end("editUser")

    u'''生成证书'''

    def create_user_cert_003(self):

        #日志开始记录
        self.log.log_start("CreateUserCert")
        #获取生成证书用户的数据
        user_data = self.get_table_data("create_cert")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.user.operate_cert(data[3])
                    self.user.create_cert()
                    cert_name = self.user.get_cert()

                    #判断生成的证书名字和指定的名字是否相等
                    self.check_without_pop_up(cert_name, data[2], data)

                    #清空标识状态
                    flag = False
                    self.switch_to_user_module()
#					self.cmf.back()
            except Exception as e:
                print("Create user cert fail: ") + str(e)
        self.log.log_end("CreateUserCert")

    u'''重新生成证书'''
    def create_user_cert_again_003(self):
        #点击保存按钮弹出框
        user_msg = self.user_msg()

        #日志开始记录
        self.log.log_start("ReCreateUserCert")
        #获取重新生成证书的数据
        user_data = self.get_table_data("reCreate_cert")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.user.operate_cert(data[2])
                    cert_num_old = self.user.get_cert_serial_num()

                    self.user.create_cert()
                    self.cmf.click_login_msg_button()
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    cert_num_new = self.user.get_cert_serial_num()

                    if cert_num_old != cert_num_new:
                        self.cmf.test_win_check_point("", "", data, True)
                    else:
                        self.cmf.test_win_check_point("", "", data, False)

                    #清空标识状态
                    flag = False
                    self.switch_to_user_module()
#					self.cmf.back()
            except Exception as e:
                print("ReCreate user cert fail: ") + str(e)
        self.log.log_end("ReCreateUserCert")

    u'''删除证书'''
    def delete_user_cert_004(self):

        #日志开始记录
        self.log.log_start("DeleteUserCert")
        #获取删除证书的数据
        user_data = self.get_table_data("delete_cert")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.user.operate_cert(data[3])
                    self.user.delete_cert()

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

                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    if self.user.get_init_cert_name() == data[2]:
                        print("Delete cert success!")
                    #清空标识状态
                    flag = False
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    #					self.switch_to_user_module()
                    self.cmf.back()
            except Exception as e:
                print("Delete user cert fail: ") + str(e)
        self.log.log_end("DeleteUserCert")

    u'''校验用户'''

    def checkout_user_005(self):
        #保存成功的弹出框
        user_msg = self.user_msg()
        #日志开始记录
        self.log.log_start("checkoutUser")
        #获取用户校验的数据
        user_data = self.get_table_data("user_check")  #user_check
        #无检查点的测试项标识,如果为True说明通过
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.user.add_button()
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.user.set_user_account(data[2])
                    self.user.set_user_name(data[3])
                    if dataRow == range(len(user_data))[-1]:
                        self.user.clear_dep()
                    self.user.set_user_pwd(data[7])
                    self.user.set_user_enquire_pwd(data[8])
                    self.user.set_user_mobile(data[9])
                    self.user.set_user_phone(data[10])
                    self.user.set_user_email(data[11])
                    self.user.save_button()

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

                    #清空标识状态
                    flag = False
            except Exception as e:
                print("checkoutUser fail: ") + str(e)
        self.switch_to_user_module()
        self.log.log_end("checkoutUser")

    u'''检索条件:用户状态'''

    def search_user_by_status_006(self):

        #日志开始记录
        self.log.log_start("Search user by status")
        #获取按照用户状态检索的数据
        user_data = self.get_table_data("search_by_status")  #user_check
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    row = self.user.search_by_status(data[3])
                    self.user.search_by_user_status(data[2])
                    self.user.click_search_button()
                    search_row = self.user.get_rows()

                    #判断测试项是否通过
                    self.check_without_pop_up(row, search_row, data)
                    self.reset()
                    #清空标识状态
                    flag = False
            except Exception as e:
                print("search user by status fail: ") + str(e)

        self.log.log_end("Search user by status")

    u'''检索条件:账号或者名称'''

    def search_user_by_username_006(self):

        #日志开始记录
        self.log.log_start("Search user by username")
        #获取按照账号或名称检索的数据
        user_data = self.get_table_data("search_by_name")  #user_check
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    row = self.user.search_direct_by_account_or_name(data[3])
                    self.user.search_accountorname(data[3])
                    self.user.click_search_button()
                    search_row = self.user.get_rows()

                    #判断测试项是否通过
                    self.check_without_pop_up(row, search_row, data)
                    self.reset()

                    #清空标识状态
                    flag = False
            except Exception as e:
                print("search user by username fail: ") + str(e)

        self.log.log_end("Search user by username")

    u'''检索条件:部门'''

    def search_user_by_dep_006(self):

        #日志开始记录
        self.log.log_start("Search user by department")
        #获取按部门检索的数据
        user_data = self.get_table_data("search_by_dep")  #user_check
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    if dataRow == 1:
                        row = self.user.search_direct_by_dep(data[3])
                        self.user.set_dep(data[3])
                    elif dataRow == 2:
                        row = self.user.get_rows()
                        self.user.click_child_node()
                        self.user.set_dep(data[3])

                    self.user.click_search_button()
                    search_row = self.user.get_rows()

                    #判断测试项是否通过
                    self.check_without_pop_up(row, search_row, data)
                    self.reset()
                    #清空标识状态
                    flag = False
            except Exception as e:
                print("search user by department fail: ") + str(e)

        self.log.log_end("Search user by department")

    u'''检索条件:角色'''

    def search_user_by_role_006(self):

        #日志开始记录
        self.log.log_start("SearchUserByRole")
        #获取按角色检索的数据
        user_data = self.get_table_data("search_by_role")  #user_check
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    row = self.user.search_direct_by_role(data[3])
                    self.user.search_user_role(data[3])
                    self.user.click_search_button()
                    search_row = self.user.get_rows()
                    #判断测试项是否通过
                    self.check_without_pop_up(row, search_row, data)
                    self.reset()
                    #清空标识状态
                    flag = False
            except Exception as e:
                print("search user by role fail: ") + str(e)

        self.log.log_end("SearchUserByRole")

    u'''删除单个用户'''

    def del_user_007(self):

        #日志开始记录
        self.log.log_start("DelOneUser")
        #获取删除用户(单个)的数据
        user_data = self.get_table_data("del_user")  #user_check
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.user.operate_delete(data[2])
                    self.cmf.click_login_msg_button()

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

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

    u'''删除全部用户'''

    def del_all_user_008(self):

        #日志开始记录
        self.log.log_start("DelAllUser")
        #获取用户删除的数据
        user_data = self.get_table_data("del_all_user")  #user_check
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    #					self.frameElem.from_frame_to_otherFrame("mainFrame")
                    #					self.user.page_select_all()
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.user.del_specified_user(data[2])
                    #self.user.select_all_button()
                    self.user.del_button()
                    self.cmf.click_login_msg_button()

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

                    #清空标识状态
                    flag = False

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


#if __name__ == "__main__":#internet explorer
#	browser = setDriver().set_local_driver()
#	commonSuite = CommonSuiteData(browser)
#	userCase = User(browser)
#	commonSuite.isomper_login()
#	cmf = commonFun(browser)
#
#	#添加角色
#	commonSuite.add_sys_role()
##	commonSuite.add_dep_role()
#	cmf.select_menu(u'运维管理')
#	cmf.select_menu(u'运维管理','用户')

#	userCase.add_user_001()
#	userCase.edit_user_002()
#	userCase.create_user_cert_003()
#	userCase.create_user_cert_again_003()
#	userCase.delete_user_cert_004()
#
#	userCase.checkout_user_005()
#	userCase.search_user_by_username_006()
#	userCase.search_user_by_status_006()
#	userCase.search_user_by_dep_006()
#	userCase.search_user_by_role_006()
#	userCase.del_user_007()
#	userCase.del_all_user_008()
コード例 #4
0
ファイル: test_audit_log.py プロジェクト: isomper/testIsomp
class testAuditLog():
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.userElem = UserPage(driver)
		self.systemLog = SystemLogPage(self.driver)
		self.auditLog = AuditLogPage(self.driver)
		self.systemLog = SystemLogPage(self.driver)
		self.tableElem = tableElement(self.driver)
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
		self.resource = Resource(driver)
		self.commonSuite = CommonSuiteData(self.driver)
	
	u'''校验没有弹出框类型用例是否通过
			parameters: 
				data : 检查点
				count :正确的行数
	'''
	def check_without_pop_up(self,count,data):
		#获取行数
		table_count = str(self.systemLog.get_table_count())
		if count == table_count:
			self.cmf.test_win_check_point("","",data,True)
		else:
			self.cmf.test_win_check_point("","",data,False)

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

	u'''运维审计检索功能'''
	def Audit_log_query_001(self):#query_type
		#日志开始记录
		self.log.log_start("AuditLogQuery_001")
		#获取配置审计检索的数据
		ad_data = self.get_table_data("audit_log_query")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(ad_data)):
			data = ad_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0 :
					self.auditLog.select_date(data[2])
					if data[3] != "":
						self.auditLog.select_depmt(data[3])
					if data[4] != "":
						self.auditLog.click_select_audit()
						self.auditLog.select_audit(data[4])
					if data[2] == "":
						self.auditLog.click_high_level(data[17])
						self.auditLog.select_audit_type(data[5])
						if data[6] != "":
							self.resource.query_type(data[6],data[7],data[8])
						self.auditLog.set_res_account(data[9])
						self.auditLog.set_user_name(data[10])
						self.auditLog.set_client_ip(data[11])
						self.userElem.set_start_time(data[12])
						self.userElem.set_end_time(data[13])
						self.auditLog.set_key_word(data[14])
						self.auditLog.set_source_ip(data[15])
						self.auditLog.set_user_account(data[16])
					self.auditLog.click_search()
					#判断测试项是否通过
					self.check_without_pop_up(data[18],data)
					#清空标识状态
					flag = False
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.userElem.click_reset_button()
			except Exception as e:
				print ("Audit Log query fail: ") + str(e)
		self.log.log_end("AuditLogQuery_001")
コード例 #5
0
class testAuditLog():
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.userElem = UserPage(driver)
		self.systemLog = SystemLogPage(self.driver)
		self.auditLog = AuditLogPage(self.driver)
		self.systemLog = SystemLogPage(self.driver)
		self.tableElem = tableElement(self.driver)
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
		self.resource = Resource(driver)
		self.commonSuite = CommonSuiteData(self.driver)
	
	u'''校验没有弹出框类型用例是否通过
			parameters: 
				data : 检查点
				count :正确的行数
	'''
	def check_without_pop_up(self,count,data):
		#获取行数
		table_count = str(self.systemLog.get_table_count())
		if count == table_count:
			self.cmf.test_win_check_point("","",data,True)
		else:
			self.cmf.test_win_check_point("","",data,False)

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

	u'''运维审计检索功能'''
	def Audit_log_query_001(self):#query_type
		#日志开始记录
		self.log.log_start("AuditLogQuery_001")
		#获取配置审计检索的数据
		ad_data = self.get_table_data("audit_log_query")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(ad_data)):
			data = ad_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0 :
					self.auditLog.select_date(data[2])
					if data[3] != "":
						self.auditLog.select_depmt(data[3])
					if data[4] != "":
						self.auditLog.click_select_audit()
						self.auditLog.select_audit(data[4])
					if data[2] == "":
						self.auditLog.click_high_level(data[17])
						self.auditLog.select_audit_type(data[5])
						if data[6] != "":
							self.resource.query_type(data[6],data[7],data[8])
						self.auditLog.set_res_account(data[9])
						self.auditLog.set_user_name(data[10])
						self.auditLog.set_client_ip(data[11])
						self.userElem.set_start_time(data[12])
						self.userElem.set_end_time(data[13])
						self.auditLog.set_key_word(data[14])
						self.auditLog.set_source_ip(data[15])
						self.auditLog.set_user_account(data[16])
					self.auditLog.click_search()
					#判断测试项是否通过
					self.check_without_pop_up(data[18],data)
					#清空标识状态
					flag = False
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.userElem.click_reset_button()
			except Exception as e:
				print ("Audit Log query fail: ") + str(e)
		self.log.log_end("AuditLogQuery_001")
コード例 #6
0
ファイル: test_system_log.py プロジェクト: isomper/testIsomp
class testSystemLog():
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.userElem = UserPage(driver)
		self.systemLog = SystemLogPage(self.driver)
		self.tableElem = tableElement(self.driver)
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
		self.loginFun = loginPage(self.driver)
		self.commonSuite = CommonSuiteData(self.driver)
	
	u'''校验没有弹出框类型用例是否通过
			parameters: 
				data : 检查点
				count :正确的行数
	'''
	def check_without_pop_up(self,count,data):
		#获取行数
		table_count = str(self.systemLog.get_table_count())
		if count == table_count:
			self.cmf.test_win_check_point("","",data,True)
		else:
			self.cmf.test_win_check_point("","",data,False)

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

	u'''配置审计检索功能'''
	def system_log_query_001(self):#query_type
		#日志开始记录
		self.log.log_start("SystemLogQuery_001")
		#获取配置审计检索的数据
		ad_data = self.get_table_data("system_log_query")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(ad_data)):
			data = ad_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0 :
					self.systemLog.select_date(data[2])
					if data[4] != "":
						self.userElem.set_dep(data[4])
						#data[4]代表是否勾选子节点(no代表不勾选)
						if data[3] != "no" :
							self.userElem.click_child_node()
					self.systemLog.select_system_log_type(data[5])
					self.systemLog.click_query()
					#判断测试项是否通过
					self.check_without_pop_up(data[6],data)
					#清空标识状态
					flag = False
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.userElem.click_reset_button()
			except Exception as e:
				print ("System Log query fail: ") + str(e)
		self.log.log_end("SystemLogQuery_001")