Пример #1
0
class LinuxResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.frameElem = frameElement(driver)
        self.resource = Resource(driver)
        self.account = Accountmgr(driver)

    u'''添加和编辑Linux资源
	   Parameters:
	      - data:excel中的一行数据
	'''

    def add_edit_linux_resource(self, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[3])
        #资源ip
        self.resource.set_resource_ip(data[4])
        #归属部门
        if data[5] != 'no':
            self.resource.set_depart(data[5])
        self.resource.select_all_agreement()
        #从IP
        if data[6] != 'no':
            self.resource.set_resource_fortIps(data[6])
        #系统版本
        if data[7] != 'no':
            self.resource.set_sys_version(data[7])
        #密码策略
        if data[8] != 'no':
            self.resource.select_pwd_strategy(data[8])
        #改密驱动名称
        if data[9] != 'no':
            self.resource.set_changePwd_driver(data[9])

        #管理员帐号
        if data[10] != 'no':
            self.resource.click_account_sync()
            self.resource.set_admin_account(data[10])
        #管理员口令
        if data[11] != 'no':
            self.resource.set_admin_pwd(data[11])
        #口令确认
        if data[12] != 'no':
            self.resource.set_confirm_pwd(data[12])
            self.resource.click_up_super()
            #提权账号口令
            self.resource.set_super_pwd(data[13])
            #确认口令
            self.resource.set_super_confirm_pwd(data[14])
        self.resource.resoure_save_button()

    u'''校验Linux资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''

    def check_linux_resource(self, datarow, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[2])
        #资源ip
        self.resource.set_resource_ip(data[3])
        #协议类型
        if data[4] != 'no':
            self.resource.select_agreement(data[4])
        #协议类型 端口
        if datarow == 7:
            self.resource.set_port(data[4], data[5])
        if datarow == 8:
            self.resource.clear_port("Ssh1")
        if datarow == 9:
            self.resource.set_port("Ssh1", data[5])
        if datarow == 12:
            self.resource.click_account_sync()
            self.resource.click_up_super()
        if datarow == 13:
            #提权账号口令
            if data[6] != 'no':
                self.resource.set_super_pwd(data[6])
            #确认口令
            if data[7] != 'no':
                self.resource.set_super_confirm_pwd(data[7])
            self.resource.set_super_prompt()
        self.resource.resoure_save_button()

    u'''添加资源账号
	   Parameters:
	      - editacttname:编辑的资源账号名称
	      - value:选择编辑方式的value值
	      - addactname:填写的资源账号名称
	      - pwd:账号口令
	      - cmfpwd:确认口令
	'''

    def add_edit_resource_account(self,
                                  editacttname='no',
                                  value='no',
                                  addactname='no',
                                  pwd='no',
                                  cmfpwd='no'):
        self.account.click_account_add_edit_button(editacttname)
        if value != 'no':
            self.account.select_edit_way(value)
        if addactname != 'no':
            self.account.set_account_name(addactname)
        if pwd != 'no':
            self.account.set_account_pwd(pwd)
        if cmfpwd != 'no':
            self.account.set_account_confirm_pwd(cmfpwd)
        self.account.set_authorize()
        self.account.click_save_account()

    u'''校验资源账号
	   Parameters:
	      - value:选择编辑方式的value值
	      - addactname:填写的资源账号名称
	      - pwd:账号口令
	      - cmfpwd:确认口令
	'''

    def check_resource_account(self,
                               value='no',
                               addactname='no',
                               pwd='no',
                               cmfpwd='no'):
        if addactname == 'no':
            self.account.clear_account_name()
        if pwd == 'no':
            self.account.clear_account_pwd()
        if cmfpwd == 'no':
            self.account.clear_account_confirm_pwd()
        if value != 'no':
            self.account.select_edit_way(value)
        if addactname != 'no':
            self.account.set_account_name(addactname)
        if pwd != 'no':
            self.account.set_account_pwd(pwd)
        if cmfpwd != 'no':
            self.account.set_account_confirm_pwd(cmfpwd)
        self.account.set_authorize()
        self.account.click_save_account()
Пример #2
0
class NetworkResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.getElem = getElement(driver)
        self.selectElem = selectElement(driver)
        self.frameElem = frameElement(driver)
        self.resource = Resource(driver)
        self.cnEn = cnEncode()

    u'''添加和编辑网络设备资源
	   Parameters:
	      - data:excel中的一行数据
	'''

    def add_edit_network_resource(self, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        if data[3] != 'no':
            self.resource.set_resource_name(data[3])
        #资源ip
        if data[5] != 'no':
            self.resource.set_resource_ip(data[5])
        #从IP
        if data[6] != 'no':
            self.resource.set_resource_fortIps(data[6])
        #归属部门
        if data[4] != 'no':
            self.resource.set_depart(data[4])

        self.resource.select_all_agreement()
        #系统版本
        if data[7] != 'no':
            self.resource.set_sys_version(data[7])
        #改密驱动名称
        if data[8] != 'no':
            self.resource.set_changePwd_driver(data[8])

        #管理员帐号
        if data[9] != 'no':
            self.resource.click_account_sync()
            self.resource.set_admin_account(data[9])
        #管理员口令
        if data[10] != 'no':
            self.resource.set_admin_pwd(data[10])
        #口令确认
        if data[11] != 'no':
            self.resource.set_confirm_pwd(data[11])
        #提权
        if data[12] != 'no':
            self.resource.click_up_super()
            #提权账号口令
            self.resource.set_super_pwd(data[12])
            #确认口令
            self.resource.set_super_confirm_pwd(data[13])
        if data[5] != 'no':
            self.resource.resoure_save_button()
        else:
            self.resource.click_save_button()

    u'''校验网络设备资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''

    def check_network_resource(self, datarow, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[2])
        #资源ip
        self.resource.set_resource_ip(data[3])
        #协议类型
        if data[4] != 'no':
            self.resource.select_agreement(data[4])
        #协议类型 端口
        if datarow == 7:
            self.resource.set_port(data[4], data[5])
        if datarow == 8:
            self.resource.clear_port("Ssh2")
        if datarow == 9:
            self.resource.set_port("Ssh2", data[5])
        if datarow == 12:
            self.resource.click_account_sync()
            self.resource.click_up_super()
        if datarow == 13:
            #提权账号口令
            if data[6] != 'no':
                self.resource.set_super_pwd(data[6])
            #确认口令
            if data[7] != 'no':
                self.resource.set_super_confirm_pwd(data[7])
            self.resource.set_super_prompt()
        self.resource.resoure_save_button()

    u'''选择telnet登录模式
	   Parameters:
	      - mode:value属性
	'''

    def telnet_login_type(self, mode):
        model = self.cnEn.is_float(mode)
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        selectelem = self.getElem.find_element_with_wait_EC(
            "id", "fortInputModelTelnet")
        self.selectElem.select_element_by_value(selectelem, model)

    u'''勾选匿名认证'''

    def check_anonymous(self):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.getElem.find_element_wait_and_click_EC("id", "anonymous_auth")
class WindowsResource(object):

	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.resource = Resource(driver)
		self.cnEn = cnEncode()

	u'''添加和编辑windows资源
	   Parameters:
	      - data:excel中的一行数据
	'''
	def add_edit_windows_resource(self, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		if data[3] != 'no':
			self.resource.set_resource_name(data[3])
		#资源ip
		if data[5] != 'no':
			self.resource.set_resource_ip(data[5])
		#从IP
		if data[6] != 'no':
			self.resource.set_resource_fortIps(data[6])
		#归属部门
		if data[4] != 'no':
			self.resource.set_depart(data[4])
		#密码策略
		if data[7] != 'no':
			self.resource.select_pwd_strategy(data[7])
		#选择所要运维协议
		self.resource.select_all_agreement()
		#windows域名
		if data[8] != 'no':
			self.set_domain_name(data[8])
		#账号分类
		if data[9] != 'no':
			self.resource.click_account_sync()
			self.select_account_type(data[9])
		#归属域控主机
		if data[10] != 'no':
			self.select_attach_domian(data[10])
		#主机名称
		if data[11] != 'no':
			self.set_host_name(data[11])
		#管理员帐号
		if data[12] != 'no':
			if data[9] == 'no':
				self.resource.click_account_sync()
			self.resource.set_admin_account(data[12])
		#管理员帐号
		if data[16] != 'no':
			self.resource.click_account_sync()
			self.select_account_protocol(data[16])
			self.set_port(data[17])
			if data[16] == "Ldap":
				self.set_ldap_account(data[18])
			else:
				self.set_ssh_account(data[18])
		#管理员口令
		if data[13] != 'no':
			self.resource.set_admin_pwd(data[13])
		#口令确认
		if data[14] != 'no':
			self.resource.set_confirm_pwd(data[14])
		#BaseDN
		if data[15] != 'no':
			self.set_base_dn(data[15])

		if data[5] != 'no':
			self.resource.resoure_save_button()
		else:
			self.resource.click_save_button()

	u'''校验windows资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''
	def check_windows_resource(self, datarow, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		self.resource.set_resource_name(data[2])
		#资源ip
		self.resource.set_resource_ip(data[3])
		#协议类型
		if data[4] != 'no':
			self.resource.select_agreement(data[4])
		#协议类型 端口
		if datarow == 7:
			self.resource.set_port(data[4], data[5])
		if datarow == 8:
			self.resource.clear_port("Vnc")
		if datarow == 9:
			self.resource.set_port("Vnc", data[5])
		if datarow == 12:
			self.resource.click_account_sync()
			self.select_account_type(data[6])
		if datarow == 13:
			self.select_attach_domian(data[7])
		self.resource.resoure_save_button()

	u'''填写windows域名
	   parameter:
	       - domainname:windows域名
	'''
	def set_domain_name(self, domainname):
		try:
			doname = self.cnEn.is_float(domainname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortDomainName")
			self.getElem.find_element_wait_and_sendkeys('id', "fortDomainName", doname)
		except Exception as e:
			print "domainname is error :" + str(e)

	u'''选择账号分类
	   Parameters:
	      - value:value属性
	'''
	def select_account_type(self, value):
		type = self.cnEn.is_float(value)
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		selectelem = self.getElem.find_element_with_wait_EC("id", "selectDisplay")
		self.selectElem.select_element_by_value(selectelem, type)

	u'''选择归属域控主机
	   parameter:
	       - text:归属域控主机的名称
	'''
	def select_attach_domian(self, text):
		try:
			domiantext = self.cnEn.is_float(text)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			selectelem = self.getElem.find_element_with_wait_EC('id', "window_select_dc")
			self.selectElem.select_element_by_visible_text(selectelem, domiantext)
		except Exception as e:
			print "Domian select error:" + str(e)

	u'''填写主机名称
	   parameter:
	       - hostname:主机名称
	'''
	def set_host_name(self, hostname):
		try:
			host = self.cnEn.is_float(hostname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "window_host_name")
			self.getElem.find_element_wait_and_sendkeys('id', "window_host_name", host)
		except Exception as e:
			print "window_host_name is error :" + str(e)

	u'''填写Base DN
	   parameter:
	       - basedn:Base DN名称
	'''
	def set_base_dn(self, basedn):
		try:
			base = self.cnEn.is_float(basedn)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortBaseDn")
			self.getElem.find_element_wait_and_sendkeys('id', "fortBaseDn", base)
		except Exception as e:
			print "fortBaseDn is error :" + str(e)

	u'''填写连接端口
	   parameter:
	       - portname:连接端口名称
	'''
	def set_port(self, portname):
		try:
			port = self.cnEn.is_float(portname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortConnectionPort")
			self.getElem.find_element_wait_and_sendkeys('id', "fortConnectionPort", port)
		except Exception as e:
			print "port is error :" + str(e)

	u'''填写ldap账号
	   parameter:
	       - actname:管理员账号
	'''
	def set_ldap_account(self, actname):
		try:
			act = self.cnEn.is_float(actname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortAdminAccount_ldap")
			self.getElem.find_element_wait_and_sendkeys('id', "fortAdminAccount_ldap", act)
		except Exception as e:
			print "name is error :" + str(e)

	u'''填写ssh账号
	   parameter:
	       - actname:管理员账号
	'''
	def set_ssh_account(self, actname):
		try:
			act = self.cnEn.is_float(actname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortAdminAccount_ssh")
			self.getElem.find_element_wait_and_sendkeys('id', "fortAdminAccount_ssh", act)
		except Exception as e:
			print "name is error :" + str(e)

	u'''选择账号同步连接协议
	   parameter:
	       - proname:同步
	'''
	def select_account_protocol(self, proname):
		try:
			pro = self.cnEn.is_float(proname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			selem = self.getElem.find_element_with_wait_EC('id', "fortConnectionProtocol")
			self.selectElem.select_element_by_visible_text(selem, pro)
		except Exception as e:
			print " protocol is error :" + str(e)

	u'''是否勾选获取所有账号'''
	def check_all_account(self):
		try:
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_click_EC('id', "get_all_accounts")
		except Exception as e:
			print " Check failure :" + str(e)
Пример #4
0
class DatabaseResource(object):
	#数据库名称
	DATABASE_NAME = "fortDatabaseName"
	#服务名
	SERVICE_NAME = "fortDatabaseServerName"
	#全选应用发布
	SELECT_ALL_APP = "add_app_release"
	#应用发布添加到右侧
	ADD_APP = "add"
	#服务名
	SERVICE_NAME = "fortDatabaseServerName"
	#BS账号属性
	ACCOUNT_ATTRIBUTE = "fortBsAccountAttribute"
	#BS表单名称
	FORM_NAME = "fortBsFormName"
	#口令属性
	PWD_ATTRIBUTE = "fortBsPasswordAttribute"
	#表单提交方式
	SUBMIT_METHOD = "submitType"
	#登录URL
	LOGIN_URL = "fortBsLoginUrl"
	#连接端口
	CONNECT_PORT = "fortDatabasePort"
	#选择归属操作系统
	SELECT_SYSTEM = "system_data_select_system"
	#归属资源IP
	SYSTEM_IP = "fortResourceIp"
	#归属资源检索
	SYSTEM_QUERY = "quick_query"
	#全选按钮
	SYSTEM_CHECK_ALL= "resource_check_all"
	#确认按钮
	SYSTEM_OK_BUTTON = "okButton"
	#取消按钮
	SYSTEM_QUIT_BUTTON = "cancelButton"

	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.log = log()
		self.resource = Resource(driver)
		self.account = Accountmgr(driver)
		self.cnEn = cnEncode()

	u'''添加和编辑database资源
		Parameters:
			- data:excel中的一行数据
	'''
	def add_edit_database_resource(self, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		self.resource.set_resource_name(data[3])
		#归属部门
		if data[4] != "":
			self.resource.set_depart(data[4])
		#资源ip
		if data[5] != "":
			self.resource.set_resource_ip(data[5])			
		#库名
		if data[6] != "":
			self.set_database_name(data[6])
		#服务名
		if data[7] != "":
			self.set_service_name(data[7])
		#密码策略
		if data[8] != "":
			self.resource.select_pwd_strategy(data[8])
		#账号属性
		if data[9] != "":
			self.set_account_attribute(data[9])
			self.set_submit_method(data[12])
			self.set_form_name(data[10])
			self.set_pwd_attribute(data[11])
			time.sleep(1)
			self.set_login_url(data[13])
		#选择客户端
		if data[14] != "":
			self.select_protocol(data[14])
		#选择应用发布
		if data[15] != "":
			self.select_application(data[15])
		#依附操作系统IP
		if data[16] != "":
			self.click_select_button()
			self.set_system_ip(data[16])
			self.click_query_button()
			self.click_check_all_button()
			self.click_confirm_button()
		#管理员帐号
		if data[17] != "":
			self.resource.click_account_sync()
			self.resource.set_admin_account(data[17])
			#管理员口令
			self.resource.set_admin_pwd(data[18])
			#口令确认
			self.resource.set_confirm_pwd(data[19])
		time.sleep(1)
		if data[5] != "":
			self.resource.resoure_save_button()
		else:
			self.resource.click_save_button()

	u'''填写资源名称'''
	def set_resource_name(self,resourceName):
		reName = self.cnEn.is_float(resourceName)
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		name = self.getElem.find_element_with_wait_EC('id','fortResourceName')
		name.clear()
		name.send_keys(reName)
	
	u'''填写资源IP'''
	def set_resource_ip(self,resourceIp):
		reIp = self.cnEn.is_float(resourceIp)
		ip = self.getElem.find_element_with_wait_EC('id','fortResourceIp')
		ip.clear()
		ip.send_keys(reIp)
		self.getElem.find_element_wait_and_click_EC("id", "spanid")
		self.getElem.find_element_with_wait_EC("classname", "ip_succ")
		time.sleep(3)
		#self.driver.implicitly_wait(5)
		
	u'''填写database库名
		parameter:
			- databaseName:数据库库名
	'''
	def set_database_name(self, databaseName):
		try:
			reName = self.cnEn.is_float(databaseName)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			name = self.getElem.find_element_with_wait_EC('id', self.DATABASE_NAME)
			name.clear()
			name.send_keys(reName)
		except Exception as e:
			print "DatabaseName is error :" + str(e)
	
	u'''填写database服务名
		parameter:
			- serviceName:数据库库名
	'''
	def set_service_name(self, serviceName):
		reName = self.cnEn.is_float(serviceName)
		try:
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			serviceName = self.getElem.find_element_with_wait_EC('id', self.SERVICE_NAME)
			serviceName.clear()
			serviceName.send_keys(reName)
		except Exception as e:
			print "ServiceName is error :" + str(e)
	
	u'''点击添加到应用发布到右侧'''
	def add_application(self):
		self.getElem.find_element_wait_and_click_EC('id',self.ADD_APP)
	
	u'''选择客户端'''
	def select_protocol(self,proName):
		reName = self.cnEn.is_float(proName)
		parent_xpath = "//table[@id='trees']/tbody/tr[7]/td[2]"
		parent_elem = self.getElem.find_element_with_wait_EC('xpath',parent_xpath)
		elems = parent_elem.find_elements_by_tag_name("span")
		for index in range(len(elems)):
			if elems[index].text == reName:
				protocol_xpath = parent_xpath + "/" + "span[" + str(index+1) + "]/input[1]"
				protocol_elem = self.getElem.find_element_with_wait_EC('xpath',protocol_xpath)
				if not protocol_elem.is_selected():
					protocol_elem.click()

	u'''选择应用发布
		parameter:
			- appStr:应用发布
	'''
	def select_application(self, appStr):
		reappStr = self.cnEn.is_float(appStr)
		appList = reappStr.split(',')
		appSelect = self.getElem.find_element_with_wait_EC('id',self.SELECT_ALL_APP)
		try:
			if appStr != "":
				for appName in appList:
					self.selectElem.select_element_by_visible_text(appSelect, appName)
					self.add_application()

		except Exception as e:
			print "Domian select error:" + str(e)

#---------------------------------BS属性--------------------------------------
	
	u'''填写BS账号属性
		parameter:
			- accountAtt:账号属性
	'''
	def set_account_attribute(self, accountAtt):
		reName = self.cnEn.is_float(accountAtt)
		try:
			accountArrbt = self.getElem.find_element_with_wait_EC('id', self.ACCOUNT_ATTRIBUTE)
			accountArrbt.clear()
			accountArrbt.send_keys(reName)
		except Exception as e:
			print "Set BS Account Attribute is error :" + str(e)
	
	u'''填写BS表单名称
		parameter:
			- formName:表单名称
	'''
	def set_form_name(self, formName):
		reName = self.cnEn.is_float(formName)
		try:
			accountArrbt = self.getElem.find_element_with_wait_EC('id', self.FORM_NAME)
			accountArrbt.clear()
			accountArrbt.send_keys(reName)
		except Exception as e:
			print "Set BS form name is error :" + str(e)
	
	u'''填写BS口令属性
		parameter:
			- pwdAtt:口令属性
	'''
	def set_pwd_attribute(self, pwdAtt):
		reATtt = self.cnEn.is_float(pwdAtt)
		try:
			pwdArrbt = self.getElem.find_element_with_wait_EC('id', self.PWD_ATTRIBUTE)
			pwdArrbt.clear()
			pwdArrbt.send_keys(reATtt)
		except Exception as e:
			print "Set BS Pwd Attribute is error :" + str(e)
	
	u'''填写BS表单提交方式
		parameter:
			- submitMethod:提交方式
	'''
	def set_submit_method(self, submitMethod):
		reMethod = self.cnEn.is_float(submitMethod)
		try:
			smtMethod = self.getElem.find_element_with_wait_EC('id', self.SUBMIT_METHOD)
			time.sleep(2)
			self.selectElem.select_element_by_value(smtMethod, reMethod)
		except Exception as e:
			print "Set BS submit method error :" + str(e)
	
	u'''填写BS登录URL
		parameter:
			- loginUrl:登录url
	'''
	def set_login_url(self, loginUrl):
		reUrl = self.cnEn.is_float(loginUrl)
		try:
			url = self.getElem.find_element_with_wait_EC('id', self.LOGIN_URL)
			url.clear()
			url.send_keys(reUrl)
		except Exception as e:
			print "Set BS login url error :" + str(e)

#--------------------------------依附操作系统----------------------------------
	
	u'''点击选择'''
	def click_select_button(self):
		
		self.getElem.find_element_wait_and_click_EC('id',self.SELECT_SYSTEM)
	
	u'''检索的依附操作系统IP'''
	def set_system_ip(self,systemIp):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		reIp = self.cnEn.is_float(systemIp)
		try:
			system_ip = self.getElem.find_element_with_wait_EC('id', self.SYSTEM_IP)
			system_ip.clear()
			system_ip.send_keys(reIp)
		except Exception as e:
			print "Set system ip error :" + str(e)
	
	u'''点击检索按钮'''
	def click_query_button(self):
		self.getElem.find_element_wait_and_click_EC('id',self.SYSTEM_QUERY)
	
	u'''点击全选按钮'''
	def click_check_all_button(self):
		self.getElem.find_element_wait_and_click_EC('id',self.SYSTEM_CHECK_ALL)
	
	u'''点击确认按钮'''
	def click_confirm_button(self):
		self.frameElem.switch_to_content()
		self.getElem.find_element_wait_and_click_EC('id',self.SYSTEM_OK_BUTTON)
	
	u'''点击取消按钮'''
	def click_quit_button(self):
		self.frameElem.switch_to_content()
		self.getElem.find_element_wait_and_click_EC('id',self.SYSTEM_QUIT_BUTTON)
	
	u'''判断是否是有ip可用性校验'''
	def is_pop_up(self):
		xpath = "html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
		flag = self.getElem.find_element_wait_and_compare_text("xpath", xpath, [0, "ip可用性校验失败!"])
		if flag:
			self.cmf.click_login_msg_button()

#--------------------------windows资源-----------------------------------------
	u'''填写windows域名
	   parameter:
	       - domainname:windows域名
	'''
	def set_domain_name(self, domainname):
		try:
			doname = self.cnEn.is_float(domainname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear_EC('id', "fortDomainName")
			self.getElem.find_element_wait_and_sendkeys('id', "fortDomainName", doname)
		except Exception as e:
			print "domainname is error :" + str(e)
	
	u'''填写主机名称
	   parameter:
	       - hostname:主机名称
	'''
	def set_host_name(self, hostname):
		try:
			host = self.cnEn.is_float(hostname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear_EC('id', "window_host_name")
			self.getElem.find_element_wait_and_sendkeys('id', "window_host_name", host)
		except Exception as e:
			print "window_host_name is error :" + str(e)
Пример #5
0
class PasswordStr():
    def __init__(self,driver):
        self.driver = driver
        self.log = log()
        self.PwdStr = PwdStrategy(self.driver)
        self.cmf = commonFun(driver)
        self.getElem = getElement(driver)
        self.cnEnde = cnEncode()
        self.dataFile = dataFileName()
        self.frameElem = frameElement(self.driver)
        self.commonsuite = CommonSuiteData(driver)
        self.user = UserPage(self.driver)
        self.session = sessionConfig(self.driver)
        self.conStr = conversationStrategy(driver)
        self.conuser = User(driver)
        self.resource = Resource(driver)
        self.account = Accountmgr(driver)
        
    u'''提示框元素路径'''
    def save_msg(self):
        save_msg = "html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
        return save_msg

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


    u'''切换至会话配置模块'''
    def switch_to_session_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 switch_to_resource_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 switch_to_pwdStr_module(self):
        self.frameElem.switch_to_content()
        self.frameElem.switch_to_top()
        self.cmf.select_menu(u"策略配置")
        self.cmf.select_menu(u"策略配置",u"密码策略")

    #添加策略
    def add_strategy_001(self):
        #日志开始记录
        self.log.log_start("pwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("add_strategy")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
            #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    time.sleep(2)
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.add_pwd_button()
                    self.PwdStr.set_pwd_name(data[2])
                    self.PwdStr.term_of_validity(data[3])
                    self.PwdStr.password_length_min(data[4])
                    self.PwdStr.password_length_max(data[5])
                    self.PwdStr.set_lower_case(data[6])
                    self.PwdStr.set_capital(data[7])
                    self.PwdStr.set_minimum_digital(data[8])
                    self.PwdStr.set_Minimum_symbol(data[9])
                    self.PwdStr.set_prohibition_of_using_keywords(data[10])
                    self.PwdStr.add_using_keywords_button()
                    self.PwdStr.save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    self.PwdStr.return_button()
            except Exception as e:
                print ("Policy adding error: ") + str(e)
        self.log.log_end("pwdStrategy")
    
    #编辑策略test
    def edit_strategy_002(self):
        #日志开始记录
        self.log.log_start("editPwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("edit_strategy")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
            #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    time.sleep(2)
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.edit(data[2])
                    self.PwdStr.set_pwd_name(data[3])
                    self.PwdStr.term_of_validity(data[4])
                    self.PwdStr.password_length_min(data[5])
                    self.PwdStr.password_length_max(data[6])
                    self.PwdStr.set_lower_case(data[7])
                    self.PwdStr.set_capital(data[8])
                    self.PwdStr.set_minimum_digital(data[9])
                    self.PwdStr.set_Minimum_symbol(data[10])
                    self.PwdStr.set_prohibition_of_using_keywords(data[11])
                    self.PwdStr.add_using_keywords_button()
                    self.PwdStr.save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    self.PwdStr.return_button()
            except Exception as e:
                print ("Policy edit error: ") + str(e)
        self.log.log_end("editPwdStrategy")
    
    #策略校验
    def check_strategy_003(self):
        #日志开始记录
        self.log.log_start("checkPwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("check_strategy")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
            #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    time.sleep(2)
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.add_pwd_button()
                    self.PwdStr.set_pwd_name(data[2])
                    self.PwdStr.term_of_validity(data[3])
                    self.PwdStr.password_length_min(data[4])
                    self.PwdStr.password_length_max(data[5])
                    self.PwdStr.set_lower_case(data[6])
                    self.PwdStr.set_capital(data[7])
                    self.PwdStr.set_minimum_digital(data[8])
                    self.PwdStr.set_Minimum_symbol(data[9])
                    self.PwdStr.set_prohibition_of_using_keywords(data[10])
                    self.PwdStr.add_using_keywords_button()
                    self.PwdStr.save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    self.PwdStr.return_button()
            except Exception as e:
                print ("Policy checkout error: ") + str(e)
        self.log.log_end("checkeditPwdStrategy")
    
    #检索名称test
    def search_strategy_004(self):
        #日志开始记录
        self.log.log_start("searchPwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("search_strategy")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
            #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.PwdStr.search_name(data[2])
                    self.PwdStr.click_search_button()
                    self.PwdStr.click_reset_button()
                    self.PwdStr.click_search_button()
                    #清空标识状态
                    flag = False
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print ("Policy search error: ") + str(e)
        self.log.log_end("searchPwdStrategy")
        
    #删除单个策略
    def del_sing_policy_005(self):
        #日志开始记录
        self.log.log_start("delPwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("del_strategy")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
            #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    time.sleep(2)
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.del_sing_strategy(data[2])
                    self.frameElem.switch_to_content()
                    self.cmf.click_msg_button(1)
                    self.cmf.test_win_check_point("xpath",saveMsg,data,flag)
                    #校验删除后的名称是否存在
                    if self.cmf.is_namevalue_exsit(data[2], "fortStrategyPasswordName"):
                        print("Delete success")
            except Exception as e:
                print ("Policy del error: ") + str(e)
        self.log.log_end("delPwdStrategy")
        
    #与密码策略关联的会话配置
    def session_association_007(self):
        #日志开始记录
        self.log.log_start("sessionAssociation")
        #获取数据
        strate_data = self.get_table_data("configure_strateg")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strate_data)):
            data = strate_data[dataRow]
            try:
            #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.switch_to_session_module()
                    time.sleep(2)
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.set_pwd_strategy(data[4])
                    self.session.add_session(data[2])
                    self.session.add_locking_time(data[3])
                    self.session.save_global_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
            except Exception as e:
                print ("session association error: ") + str(e)
        self.log.log_end("sessionAssociation")
                    
    #与密码策略关联的用户
    def user_association_008(self):
        #日志开始记录
        self.log.log_start("userAssociation")
        #获取数据
        strate_data = self.get_table_data("user_association")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strate_data)):
            data = strate_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.conuser.switch_to_user_module()
                    time.sleep(2)
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.user_edit(data[2])
                    self.PwdStr.set_pwd(data[9])
                    self.PwdStr.set_pwd_agin(data[10])
                    self.user.save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    self.user.click_back_button()
            except Exception as e:
                print ("user association error: ") + str(e)
        self.log.log_end("userAssociation")
    
    #为Windows资源添加密码策略
    def resource_association_009(self):
        #日志开始记录
        self.log.log_start("resourAcessociation")
        #获取数据
        strate_data = self.get_table_data("resource_association")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strate_data)):
            data = strate_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    time.sleep(2)
                    self.commonsuite.sys_switch_to_dep()
                    self.switch_to_resource_module()
                    time.sleep(2)
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.resource_edit(data[2])
                    self.PwdStr.set_resource_strategy(data[8])
                    self.resource.resoure_save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    self.PwdStr.return_button()
            except Exception as e:
                print ("resour acessociation error: ") + str(e)
        self.log.log_end("resourAcessociation")
    
    #为Windows资源账号添加密码策略
    def resource_account_association_010(self):
        #日志开始记录
        self.log.log_start("resourAceccountAssociation")
        #获取数据
        strate_data = self.get_table_data("resource_account_association")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strate_data)):
            data = strate_data[dataRow]
            try:
            #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    time.sleep(2)
                    self.PwdStr.account_manage(data[2])
                    self.account.click_account_add()
                    self.PwdStr.set_resource_account_name(data[3])
                    self.PwdStr.set_resource_account_pwd(data[4])
                    self.PwdStr.set_resource_account_pwdagin(data[5])
                    self.PwdStr.save_account()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    #点击资源账号编辑页面返回
                    self.PwdStr.return_button()
                    #点击资源账号页面返回
                    self.PwdStr.return_button()
            except Exception as e:
                print ("resour aceccount association error: ") + str(e)
        self.log.log_end("resourAceccountAssociation")

                
    #删除全部策略
    def del_all_policy_006(self):
        #日志开始记录
        self.log.log_start("delAllPwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("del_all_strategy")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
            #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    time.sleep(2)
                    self.commonsuite.dep_switch_to_sys()
                    self.switch_to_pwdStr_module()
                    time.sleep(2)
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.select_all_button()
                    self.PwdStr.del_button()
                    self.frameElem.switch_to_content()
                    self.cmf.click_msg_button(1)
                    self.cmf.test_win_check_point("xpath",saveMsg,data,flag)
                    #校验删除后的名称是否存在
                    if self.cmf.is_namevalue_exsit(data[2], "fortStrategyPasswordName"):
                        print("Delete all success")
            except Exception as e:
                print ("Policy delAll error: ") + str(e)
        self.log.log_end("delAllPwdStrategy")
    
#if __name__ == "__main__":
#    browser = setDriver().set_local_driver()
#    commonSuite = CommonSuiteData(browser)
#    pwdCase = PasswordStr(browser)
#    commonSuite.pwdstr_module_prefix_condition()
#    pwdCase.add_strategy_001()
#    pwdCase.edit_strategy_002()
#    pwdCase.check_strategy_003()
#    pwdCase.search_strategy_004()
#    pwdCase.del_sing_policy_005()
#    pwdCase.session_association_007()
#    pwdCase.user_association_008()
#    pwdCase.resource_association_009()
#    pwdCase.resource_account_association_010()
#    pwdCase.del_all_policy_006()
#    commonSuite.pwdstr_module_post_condition()
Пример #6
0
class testDatabaseResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.cmf = commonFun(driver)
        self.getElem = getElement(driver)
        self.frameElem = frameElement(driver)
        self.resource = Resource(driver)
        self.database = DatabaseResource(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_database_table_data(self, sheetname):
        dataFile = dataFileName()
        databasePath = dataFile.get_database_test_url()
        databaseData = dataFile.get_data(databasePath, sheetname)
        return databaseData

    u'''添加database资源'''

    def add_database_resource_001(self):

        #日志开始记录
        self.log.log_start("add_database_resource")
        #获取添加windows资源测试数据
        databaseData = self.get_database_table_data("add_database_resource")
        #保存成功的弹出框
        windowsMsg = self.div_msg()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        for dataRow in range(len(databaseData)):
            data = databaseData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.resource.click_add_edit_button()
                    self.resource.select_resource_type(data[2])
                    self.database.add_edit_database_resource(data)
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", windowsMsg, data,
                                                  flag)
                    time.sleep(2)
                    self.cmf.back()
            except Exception as e:
                print("add_database_resource fail:" + str(e))

        self.log.log_end("add_database_resource")

    u'''编辑database资源'''

    def edit_database_resource_002(self):

        #日志开始记录
        self.log.log_start("edit_database_resource")
        #获取编辑windows资源测试数据
        databaseData = self.get_database_table_data("edit_database_resource")
        #保存成功的弹出框
        windowsMsg = self.div_msg()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        for dataRow in range(len(databaseData)):
            data = databaseData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.resource.click_add_edit_button(data[2])
                    self.database.add_edit_database_resource(data)
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", windowsMsg, data,
                                                  flag)
                    self.cmf.back()
            except Exception as e:
                print("edit_database_resource fail:" + str(e))

        self.log.log_end("edit_database_resource")

    '''数据库校验'''

    def check_database_resource_003(self):
        #日志开始记录
        self.log.log_start("check_database_resource")
        #获取编辑windows资源测试数据
        databaseData = self.get_database_table_data("check_database_resource")
        #保存成功的弹出框
        windowsMsg = self.div_msg()

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        #点击添加按钮
        self.resource.click_add_edit_button()
        #选择windows类型
        self.resource.select_resource_type("Oracle10g")

        for dataRow in range(len(databaseData)):
            data = databaseData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    #资源名称
                    self.database.set_resource_name(data[2])
                    self.database.set_resource_ip(data[3])
                    self.database.set_database_name(data[4])
                    self.database.set_service_name(data[5])
                    if data[6] != "":
                        self.database.select_protocol(data[6])
                    if data[7] != "":
                        self.database.select_application(data[7])

                    self.resource.resoure_save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", windowsMsg, data,
                                                  flag)

            except Exception as e:
                print("check_database_resource fail:" + str(e))
        self.cmf.back()
        self.database.is_pop_up()
        self.log.log_end("check_database_resource")