Exemple #1
0
class Dobapproval(object):
    def __init__(self, driver):
        self.driver = driver
        self.getElem = getElement(driver)
        self.selectElem = selectElement(driver)
        self.frameElem = frameElement(driver)
        self.cmf = commonFun(driver)
        self.log = log()
        self.cnEn = cnEncode()
        self.depart = Department(driver)
        self.loginElem = loginPage(self.driver)
        self.authElem = AuthorizationPage(self.driver)
        self.acproval = Accapproval(driver)

    u'''点击授权操作列双人授权按钮
        parameters:
            name : 授权名称
    '''

    def click_double_license_button(self, name):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.authElem.operate_double_approval(name)

    u'''点击双人审批图标
            parameters :
                rename : 资源名称
    '''

    def click_double_license_icon(self, rename):
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        rname = self.cnEn.is_float(rename)
        row = self.acproval.select_resoure_sso(rname)
        xpath = "/html/body/div[1]/div[7]/div[2]/div/table/tbody/tr[" + str(
            row * 2) + "]/td/div/table/tbody/tr/td[2]/a/img"
        time.sleep(2)
        self.getElem.find_element_wait_and_click_EC("xpath", xpath)
        time.sleep(2)

    u'''校验图标
	   parameters :
            - rename:资源名称
	'''

    def check_ico_len(self, rename):
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        time.sleep(3)
        row = self.acproval.select_resoure_sso(rename)
        self.acproval.click_refresh_icon(rename)
        ico_xpath = "/html/body/div[1]/div[7]/div[2]/div[1]/table/tbody/tr[" + str(
            row * 2) + "]/td/div/table/tbody/tr/td[2]"
        time.sleep(2)
        selem = self.getElem.find_element_with_wait_EC("xpath", ico_xpath)
        selems = selem.find_elements_by_tag_name("a")
        lengh = len(selems)
        if lengh > 1:
            self.log.log_detail(u"双人授权已同意申请,可以进行单点登录", True)
        else:
            self.log.log_detail(u"双人授权已拒绝申请,不可以进行单点登录", True)

    u'''选择授权人
       parameters :
            - authorizer:授权人名称
    '''

    def select_authorizer(self, authorizer):
        self.frameElem.switch_to_artIframe()
        author = self.cnEn.is_float(authorizer)
        selem = self.getElem.find_element_with_wait_EC("id", "fortApproverId")
        self.selectElem.select_element_by_visible_text(selem, author)

    u'''勾选同终端直接输入口令访问'''

    def check_same_termina(self):
        self.frameElem.switch_to_artIframe()
        self.getElem.find_element_wait_and_click_EC("id", "fortIsRemoteApply")

    u'''填写授权人密码
	   Parameters:
	      - passwd:授权人密码
	'''

    def set_authorizer_pwd(self, passwd):
        self.frameElem.switch_to_artIframe()
        pwd = self.cnEn.is_float(passwd)
        self.getElem.find_element_wait_and_clear("id", "password")
        self.getElem.find_element_wait_and_sendkeys("id", "password", pwd)

    u'''调用新浏览器'''

    def call_other_browsers(self):
        newbrowser = webdriver.Ie()
        # newbrowser = webdriver.Chrome()
        #IE窗口最大化
        newbrowser.maximize_window()
        newbrowser.get("https://172.16.10.155")
        newbrowser.get(
            "javascript:document.getElementById('overridelink').click();")
        return newbrowser

    u'''远程用户登录
	   Parameters:
          - listusers:用户集
	'''

    def user_remote_approval(self, newbrowser, listusers):
        users = listusers.split()
        newbrowser.switch_to_default_content()
        selem = newbrowser.find_element_by_id("loginMethod")
        Select(selem).select_by_value(users[0])
        newbrowser.find_element_by_id("username").click()
        newbrowser.find_element_by_id("username").send_keys(users[1])
        newbrowser.find_element_by_id("pwd").click()
        newbrowser.find_element_by_id("pwd").send_keys(users[2])
        time.sleep(1)
        newbrowser.find_element_by_id("do_login").click()

    u'''菜单选择
        Parameters:
            - newbrowser:新浏览器驱动
            - levelText1:1级菜单文本
            - levelText2:2级菜单文本
            - levelText3:3级菜单文本
    '''

    def click_menu(self,
                   newbrowser,
                   levelText1,
                   levelText2='no',
                   levelText3='no'):

        self.remote_break_frame(newbrowser, "topFrame")
        #点击一级菜单
        newbrowser.find_element_by_link_text(levelText1).click()
        time.sleep(1)
        #如果有2级菜单,再点击2级菜单
        if levelText2 != 'no':
            newbrowser.find_element_by_link_text(levelText2).click()
        #如果有3级菜单,根据名称点击3级菜单
        if levelText3 != 'no':
            self.remote_break_frame(newbrowser, "leftFrame")
            newbrowser.find_element_by_link_text(levelText3).click()

    u'''判断名称是否存在
       Parameters:
          - namevalue:传入的要被查询名称
          - name:表格列的name属性
       return:true代表存在,false代表不存在
    '''

    def namevalue_remote_is_exsit(self, newbrowser, namevalue, name):
        nameval = self.cnEn.is_float(namevalue)
        namesex = self.cnEn.is_float(name)
        isExsit = False
        text_list = newbrowser.find_elements_by_name(namesex)
        for fortNameValue in text_list:
            fortNameValue_text = fortNameValue.text
            if fortNameValue_text == nameval:
                isExsit = True
                break
        return isExsit

    u'''查询已存在名称位于第几行
       Parameters:
          - namevalue:传入的要被查询名称
          - name:表格列的name属性
       return:定位该名称位于第几行
    '''

    def find_name_remote_by_row(self, newbrowser, namevalue, name):
        self.remote_break_frame(newbrowser, "mainFrame")
        nameval = self.cnEn.is_float(namevalue)
        namesex = self.cnEn.is_float(name)
        row = 0
        if self.namevalue_remote_is_exsit(newbrowser, nameval, namesex):
            text_list = newbrowser.find_elements_by_name(namesex)
            for fortNameValue in text_list:
                row = row + 1
                fortNameValue_text = fortNameValue.text
                if fortNameValue_text == nameval:
                    break
        return row

    u'''通过流程号点击要审批的信息
	   Parameters:
          - number:流程号
	'''

    def click_remote_approval_by_number(self, newbrowser, number):
        row = self.find_name_remote_by_row(newbrowser, number,
                                           "fortProcessInstanceId")
        xpath = "/html/body/form/div/div[7]/div[2]/div/table/tbody/tr[" + str(
            row) + "]/td[8]/input[1]"
        newbrowser.find_element_by_xpath(xpath).click()

    u'''流程控制是否同意审批
	   Parameters:
          - status:1代表同意审批,2代表拒绝审批
	'''

    def process_remote_is_agree_approval(self, newbrowser, status):
        statu = self.cnEn.is_float(status)
        self.remote_break_frame(newbrowser, "mainFrame")
        if statu == '1':
            newbrowser.find_element_by_id("yes").click()
        elif statu == '2':
            newbrowser.find_element_by_id("no").click()

    u'''填写流程控制中审批申请单的描述
	   Parameters:
          - description:描述内容
	'''

    def set_process_remote_description(self, newbrowser, description):
        descri = self.cnEn.is_float(description)
        self.remote_break_frame(newbrowser, "mainFrame")
        newbrowser.find_element_by_id("fortApprovalOpinions").clear()
        newbrowser.find_element_by_id("fortApprovalOpinions").send_keys(descri)

    u'''点击提交按钮'''

    def click_remote_submit(self, newbrowser):
        self.remote_break_frame(newbrowser, "mainFrame")
        newbrowser.find_element_by_id("save_process_approval").click()

    u'''点击确定按钮'''

    def click_remote_msg_button(self, newbrowser):
        newbrowser.switch_to_default_content()
        OKBTN = "//div[@id='aui_buttons']/button[1]"
        newbrowser.find_element_by_xpath(OKBTN).click()

    u'''点击返回按钮'''

    def remote_back(self, newbrowser):
        self.remote_break_frame(newbrowser, "mainFrame")
        newbrowser.find_element_by_id("history_skip").click()

    u'''跳转frame
	   Parameters:
            - frameName:要跳转到的frame的名字
	'''

    def remote_break_frame(self, newbrowser, frameName):
        newbrowser.switch_to_default_content()
        newbrowser.switch_to_frame("content1")
        newbrowser.switch_to_frame(frameName)

    u'''点击退出'''

    def remote_quit(self, newbrowser):
        self.remote_break_frame(newbrowser, "topFrame")
        time.sleep(1)
        newbrowser.find_element_by_id("logout").click()

    u'''申请人发送双人审批申请
	   Parameters:
          - data:excel中的一行数据
	'''

    def send_double_license_applicant(self, data):
        self.acproval.select_resoure_account(data[1], data[2])
        self.click_double_license_icon(data[1])
        self.select_authorizer(data[3])
        if data[4] != 'no':
            self.check_same_termina()
            self.set_authorizer_pwd(data[4])
        self.acproval.set_operation_description(data[5])
        self.acproval.click_sure_button()
        self.driver.implicitly_wait(10)
        self.log.log_detail(data[0], True)

    u'''审批人通过当前浏览器流程控制进行审批
	   Parameters:
          - number:流程号
	'''

    def approver_by_process_approval(self, expData, number):

        xpathMsg = ".//*[@id='body1']/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(expData)):
            data = expData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    self.acproval.user_login(data[2])
                    self.frameElem.from_frame_to_otherFrame("topFrame")
                    self.cmf.select_menu(u"流程控制", u"流程任务")
                    self.acproval.click_approval_by_number(number)
                    if data[1] != 'no':
                        self.frameElem.switch_to_content()
                        self.cmf.test_win_check_point("xpath", xpathMsg, data,
                                                      flag)
                    else:
                        self.acproval.process_is_agree_approval(data[3])
                        self.acproval.set_process_apply_description(data[4])
                        self.acproval.click_submit()
                        self.cmf.click_login_msg_button()
                    self.acproval.back_quit_common()
            except Exception as e:
                print("expired_approvel fail:" + str(e))

    u'''审批人通过新开启的浏览器流程控制进行审批
	   Parameters:
          - number:流程号
	'''

    def approver_remote_approval(self, expData, number):
        for dataRow in range(len(expData)):
            data = expData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    newbrowser = self.call_other_browsers()
                    self.user_remote_approval(newbrowser, data[1])
                    self.click_menu(newbrowser, u"流程控制", u"流程任务")
                    self.click_remote_approval_by_number(newbrowser, number)
                    self.process_remote_is_agree_approval(newbrowser, data[2])
                    self.set_process_remote_description(newbrowser, data[3])
                    self.click_remote_submit(newbrowser)
                    self.click_remote_msg_button(newbrowser)
                    self.remote_back(newbrowser)
                    self.driver.implicitly_wait(5)
                    self.remote_quit(newbrowser)
                    newbrowser.quit()
            except Exception as e:
                print("expired_approvel fail:" + str(e))
Exemple #2
0
class CommandRule(object):
	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.cmf = commonFun(driver)
		self.cnEn = cnEncode()
		self.acproval = Accapproval(driver)
		self.ssoElem = SsoPage(self.driver)

	u'''左边框点击规则
	   Parameters:
            - statu:左边框点击,0代表点击命令规则,1代表点击时间规则,2代表点击地址规则,3代表点击资源时间规则
	'''
	def click_left_rule(self, statu):
		self.frameElem.from_frame_to_otherFrame("leftFrame")
		if statu == 0:
			#点击命令规则
			self.getElem.find_element_wait_and_click_EC("id", "url0")
		elif statu == 1:
			#点击时间规则
			self.getElem.find_element_wait_and_click_EC("id", "url1")
		elif statu == 2:
			#点击地址规则
			self.getElem.find_element_wait_and_click_EC("id", "url2")
		elif statu == 3:
			#点击资源时间规则
			self.getElem.find_element_wait_and_click_EC("id", "url3")

	u'''点击添加'''
	def click_add_button(self):
		time.sleep(1)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("classname", "btn_tj")

	u'''点击删除'''
	def click_del_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "delete_rule_command")

	u'''点击复选框全选'''
	def check_all(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "checkbox")

	u'''点击部署'''
	def click_deploy_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "updateAllState")

	u'''选择命令类型
       Parameters:
            - value:select选项中的value属性值,0代表黑名单,2代表审批命令
    '''
	def select_command_type(self, value):
		valu = self.cnEn.is_float(value)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		selem = self.getElem.find_element_with_wait_EC("id", "fortRuleCommandTypeList")
		self.selectElem.select_element_by_value(selem, valu)

	u'''填写命令
	   Parameters:
            - command:命令内容
	'''
	def set_command(self, command):
		comm = self.cnEn.is_float(command)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_clear("id", "new_command")
		self.getElem.find_element_wait_and_sendkeys("id", "new_command", comm)

	u'''清空已添加命令'''
	def clear_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		inputelems = self.driver.find_elements_by_name("passwordTable")
		for inputelem in inputelems:
			inputelem.click()

	u'''点击添加命令按钮'''
	def click_add_command_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "add_command")

	u'''测试命令
	   Parameters:
            - command:命令内容
	'''
	def set_test_command(self, command):
		comm = self.cnEn.is_float(command)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_clear("id", "test")
		self.getElem.find_element_wait_and_sendkeys("id", "test", comm)

	u'''点击测试命令按钮'''
	def click_test_command_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "test_command")

	u'''点击添加用户按钮'''
	def click_add_users_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn_tjyh")

	u'''点击添加用户组按钮'''
	def click_add_usergroup_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn_tjyhz")

	u'''点击添加资源按钮'''
	def click_add_resource_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn_tjzyzy")

	u'''点击添加资源组按钮'''
	def click_add_regroup_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn01_tjyhz")

	u'''点击添加资源账号按钮'''
	def click_add_reaccount_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn_tjzy")

	u'''点击删除资源按钮'''
	def click_del_resource_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "del_resource")

	u'''点击删除资源账号按钮'''
	def click_del_reaccount_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "del_account")

	u'''点击保存按钮'''
	def click_save_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "save_rule_command")

	u'''点击返回按钮'''
	def click_back_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "history_skip")

	u'''点击审批人按钮'''
	def click_approver_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn_tjspr")

	u'''点击用户检索按钮'''
	def click_check_user(self):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_click_EC("id", "quick_user")

	u'''点击资源检索按钮'''
	def click_check_resource(self):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_click_EC("id", "quick_query")

	u'''勾选全部用户'''
	def check_all_user(self):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.click_check_user()
		self.getElem.find_element_wait_and_click_EC("id", "user_check_all")
		self.check_sure_button()

	u'''勾选全部资源'''
	def check_all_resource(self):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.click_check_resource()
		self.getElem.find_element_wait_and_click_EC("id", "resource_check_all")
		self.check_sure_button()

	u'''点击确定按钮'''
	def check_sure_button(self):
		self.frameElem.switch_to_content()
		self.getElem.find_element_wait_and_click_EC("id", "okButton")

	u'''填写插入行数
	   Parameters:
            - row:行数
	'''
	def set_row_command(self, row):
		rows = self.cnEn.is_float(row)
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_clear("id", "rows")
		self.getElem.find_element_wait_and_sendkeys("id", "rows", rows)

	u'''点击插入行数的返回按钮'''
	def click_cancel_button(self):
		self.frameElem.switch_to_content()
		self.getElem.find_element_wait_and_click_EC("id", "cancelButton")

	u'''勾选用户
	   parameter:
		   - listuser:用户集合
	'''
	def check_user_command(self, listuser):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		# 获取table对象
		tableelem = self.getElem.find_element_with_wait_EC("id", "user_table")
		self.check_common(tableelem, listuser)

	u'''勾选资源
	   parameter:
		   - listresource:资源集合
	'''
	def check_resource_command(self, listresource):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		# 获取table对象
		tableelem = self.getElem.find_element_with_wait_EC("id", "resourceTable")
		self.check_common(tableelem, listresource)

	u'''勾选用户或者资源公共方法
	   parameter:
		   - tableelem:表属性对象
		   - lists:用户集合
	'''
	def check_common(self, tableelem, lists):
		# 获取table对象下的所有tr
		trelems = tableelem.find_elements_by_tag_name("tr")
		# 位于第几行
		line = 0

		# 循环所有tr
		for trelem in trelems:
			line += 1
			# 找到tr下所有td对象
			tds = trelem.find_elements_by_tag_name("td")
			# 获取td[2]的文本
			tdtext = tds[1].text
			for user in lists.split():
				if tdtext == user:
					xpath = "/html/body/div[3]/div[2]/table/tbody/tr[" + str(line) + "]/td[1]/li/input"
					self.getElem.find_element_wait_and_click_EC("xpath", xpath)
					break

	u'''勾选用户组
	   parameter:
		   - listuser:用户集合
	'''
	def check_usergroup_command(self, usergroups):
		self.check_group_common("userGroup_1_switch", "userGroup", usergroups, "userGroup_")

	u'''勾选资源组
	   parameter:
		   - listuser:用户集合
	'''
	def check_regroup_command(self, regroups):
		self.check_group_common("resourceGroup_1_switch", "resourceGroup", regroups, "resourceGroup_")

	u'''勾选组的公共方法
	   parameter:
		   - extendid:闭合按钮的id属性
		   - ulid:ul的id属性
		   - groups:组集合
		   - idfirst:span标签的id属性数字前面的字符
	'''
	def check_group_common(self, extendid, ulid, groups, idfirst):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_click_EC("id", extendid)
		# 获取ul对象
		ulelem = self.getElem.find_element_with_wait_EC("id", ulid)
		# 获取ul对象下的所有a
		aelems = ulelem.find_elements_by_tag_name("a")

		for elem in aelems:
			#获取tr的title属性
			atext = elem.get_attribute("title")
			for usergrop in groups.split():
				if atext == usergrop:
					#获取tr的id属性
					aid = elem.get_attribute("id")
					spanid = idfirst + filter(str.isdigit, aid) + "_check"
					self.getElem.find_element_wait_and_click_EC("id", spanid)
					break

	u'''点击操作的公共方法
	   parameter:
		   - value:序号
		   - statu:代表点击的操作,1代表勾选复选框;2代表状态开关;3代表上移;4代表下移;5代表插入;6代表编辑
	'''
	def click_action_public_command(self, value, status):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		valu = self.cnEn.is_float(value)
		statu = self.cnEn.is_float(status)
		# 获取table对象
		tableelem = self.getElem.find_element_with_wait_EC("id", "content_table")
		# 获取table对象下的所有tr
		trelems = tableelem.find_elements_by_tag_name("tr")
		# 位于第几行
		line = 0

		# 循环所有tr
		for trelem in trelems:
			line += 1
			# 找到tr下所有td对象
			tds = trelem.find_elements_by_tag_name("td")
			# 获取td[2]的文本
			tdtext = tds[1].text

			if tdtext == valu:
				#勾选复选框
				if statu == '1':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[1]/input[1]"
				#状态开关
				elif statu == '2':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[8]/input[1]"
				#上移
				elif statu == '3':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[1]"
				#下移
				elif statu == '4':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[2]"
				#插入
				elif statu == '5':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[3]"
				#编辑
				elif statu == '6':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[4]"
				self.getElem.find_element_wait_and_click_EC("xpath", xpath)
				break

	u'''点击消息提示'''
	def click_message_prompt(self):
		self.frameElem.from_frame_to_otherFrame('topFrame')
		self.getElem.find_element_wait_and_click_EC("id", "link_tc")

	u'''点击消息详情'''
	def click_message_detail(self):
		self.frameElem.from_frame_to_otherFrame('topFrame')
		time.sleep(3)
		self.click_message_prompt()
		time.sleep(2)
		ulselem = self.getElem.find_element_with_wait_EC("id", "digest")
		# 找到ul下所有a对象
		aselems = ulselem.find_elements_by_tag_name("a")
		aselems[0].click()

	u'''选择审批用户
	   parameter:
		   - username:审批用户名称
	'''
	def select_approval_user(self, username):
		self.frameElem.from_frame_to_otherFrame('artIframe')
		name = self.cnEn.is_float(username)
		elem = self.getElem.find_element_with_wait_EC("id", "fortApproverId")
		self.selectElem.select_element_by_visible_text(elem, name)

	u'''填写口令
	   Parameters:
            - pwd:口令
	'''
	def set_passwd(self, pwd):
		passwd = self.cnEn.is_float(pwd)
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_clear("id", "password")
		self.getElem.find_element_wait_and_sendkeys("id", "password", passwd)

	u'''填写备注信息
	   Parameters:
            - descrip:备注信息
	'''
	def set_descrip(self, descrip):
		description = self.cnEn.is_float(descrip)
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_clear("id", "fortDescription")
		self.getElem.find_element_wait_and_sendkeys("id", "fortDescription", description)

	u'''通过消息进行命令审批
	   Parameters:
            - user:用户名称
            - pwd:密码
            - descrip:备注信息
	'''
	def command_by_message_approval(self, user, pwd, descrip):
		self.frameElem.switch_to_content()
		time.sleep(5)
		self.click_message_detail()
		time.sleep(2)
		self.select_approval_user(user)
		time.sleep(1)
		self.set_passwd(pwd)
		self.set_descrip(descrip)
		self.check_sure_button()
		time.sleep(2)

	u'''通过流程控制进行命令审批
	   Parameters:
            - user:用户名称
            - pwd:密码
            - descrip:备注信息
	'''
	def command_by_flow_approval(self, user, pwd, descrip):
		#获取流程号
		number = self.acproval.get_new_process_number()
		self.cmf.select_menu(u"流程控制", u"流程任务")
		self.acproval.click_approval_by_number(number)
		self.select_approval_user(user)
		self.set_passwd(pwd)
		self.set_descrip(descrip)
		self.check_sure_button()

	u'''根据浏览器类型进行单点登录'''
	def choice_browser_open(self,iconType,username,pwd,cmdList):
		fileList = fileRead().get_ip_address()
		browserType = fileList[1].strip('\n')
		if browserType == '1':
			time.sleep(5)
			self.ssoElem.execute_chrome_key()
		elif browserType != '0' or browserType != '1':
			self.ssoElem.opt_cmd("\\testIsomp\\webElement\\sso\\sso_firefox.exe","", "","","")
		time.sleep(3)
		self.ssoElem.opt_cmd("\\testIsomp\\webElement\\rule\\sso_command_open.exe",iconType, username,pwd,cmdList)

	u'''根据浏览器类型关闭单点登录'''
	def choice_browser_close(self,iconType):
		self.ssoElem.opt_cmd("\\testIsomp\\webElement\\rule\\sso_command_close.exe",iconType,"","","")

	u'''命令审批单点登录'''
	def sso_command(self, data):
		time.sleep(2)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.ssoElem.select_account(data[2],data[3])
		self.click_sso_icon(data[2])
		if data[4] != "":
			self.ssoElem.select_protocol(data[4])
		time.sleep(5)
		SendKeys.SendKeys(str(data[5]))
		SendKeys.SendKeys('\n', with_newlines=True)
		time.sleep(2)

	u'''点击单点登录图标
		parameters :
			rename : 资源名称
	'''
	def click_sso_icon(self, rename):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		rname = self.cnEn.is_float(rename)
		row = self.acproval.select_resoure_sso(rname)
		xpath = "/html/body/div[1]/div[7]/div[2]/div/table/tbody/tr[" + str(
			row * 2) + "]/td/div/table/tbody/tr/td[2]/a/img"
		time.sleep(2)
		self.getElem.find_element_wait_and_click_EC("xpath", xpath)
		time.sleep(2)
class CommandRule(object):
	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.cmf = commonFun(driver)
		self.cnEn = cnEncode()
		self.acproval = Accapproval(driver)
		self.ssoElem = SsoPage(self.driver)

	u'''左边框点击规则
	   Parameters:
            - statu:左边框点击,0代表点击命令规则,1代表点击时间规则,2代表点击地址规则,3代表点击资源时间规则
	'''
	def click_left_rule(self, statu):
		self.frameElem.from_frame_to_otherFrame("leftFrame")
		if statu == 0:
			#点击命令规则
			self.getElem.find_element_wait_and_click_EC("id", "url0")
		elif statu == 1:
			#点击时间规则
			self.getElem.find_element_wait_and_click_EC("id", "url1")
		elif statu == 2:
			#点击地址规则
			self.getElem.find_element_wait_and_click_EC("id", "url2")
		elif statu == 3:
			#点击资源时间规则
			self.getElem.find_element_wait_and_click_EC("id", "url3")

	u'''点击添加'''
	def click_add_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("classname", "btn_tj")

	u'''点击删除'''
	def click_del_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "delete_rule_command")

	u'''点击复选框全选'''
	def check_all(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "checkbox")

	u'''点击部署'''
	def click_deploy_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "updateAllState")

	u'''选择命令类型
       Parameters:
            - value:select选项中的value属性值,0代表黑名单,2代表审批命令
    '''
	def select_command_type(self, value):
		valu = self.cnEn.is_float(value)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		selem = self.getElem.find_element_with_wait_EC("id", "fortRuleCommandTypeList")
		self.selectElem.select_element_by_value(selem, valu)

	u'''填写命令
	   Parameters:
            - command:命令内容
	'''
	def set_command(self, command):
		comm = self.cnEn.is_float(command)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_clear("id", "new_command")
		self.getElem.find_element_wait_and_sendkeys("id", "new_command", comm)

	u'''清空已添加命令'''
	def clear_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		inputelems = self.driver.find_elements_by_name("passwordTable")
		for inputelem in inputelems:
			inputelem.click()

	u'''点击添加命令按钮'''
	def click_add_command_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "add_command")

	u'''测试命令
	   Parameters:
            - command:命令内容
	'''
	def set_test_command(self, command):
		comm = self.cnEn.is_float(command)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_clear("id", "test")
		self.getElem.find_element_wait_and_sendkeys("id", "test", comm)

	u'''点击测试命令按钮'''
	def click_test_command_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "test_command")

	u'''点击添加用户按钮'''
	def click_add_users_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn_tjyh")

	u'''点击添加用户组按钮'''
	def click_add_usergroup_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn_tjyhz")

	u'''点击添加资源按钮'''
	def click_add_resource_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn_tjzyzy")

	u'''点击添加资源组按钮'''
	def click_add_regroup_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn01_tjyhz")

	u'''点击添加资源账号按钮'''
	def click_add_reaccount_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn_tjzy")

	u'''点击删除资源按钮'''
	def click_del_resource_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "del_resource")

	u'''点击删除资源账号按钮'''
	def click_del_reaccount_button(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "del_account")

	u'''点击保存按钮'''
	def click_save_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "save_rule_command")

	u'''点击返回按钮'''
	def click_back_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "history_skip")

	u'''点击审批人按钮'''
	def click_approver_command(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn_tjspr")

	u'''点击用户检索按钮'''
	def click_check_user(self):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_click_EC("id", "quick_user")

	u'''点击资源检索按钮'''
	def click_check_resource(self):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_click_EC("id", "quick_query")

	u'''勾选全部用户'''
	def check_all_user(self):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.click_check_user()
		self.getElem.find_element_wait_and_click_EC("id", "user_check_all")
		self.check_sure_button()

	u'''勾选全部资源'''
	def check_all_resource(self):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.click_check_resource()
		self.getElem.find_element_wait_and_click_EC("id", "resource_check_all")
		self.check_sure_button()

	u'''点击确定按钮'''
	def check_sure_button(self):
		self.frameElem.switch_to_content()
		self.getElem.find_element_wait_and_click_EC("id", "okButton")

	u'''填写插入行数
	   Parameters:
            - row:行数
	'''
	def set_row_command(self, row):
		rows = self.cnEn.is_float(row)
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_clear("id", "rows")
		self.getElem.find_element_wait_and_sendkeys("id", "rows", rows)

	u'''点击插入行数的返回按钮'''
	def click_cancel_button(self):
		self.frameElem.switch_to_content()
		self.getElem.find_element_wait_and_click_EC("id", "cancelButton")

	u'''勾选用户
	   parameter:
		   - listuser:用户集合
	'''
	def check_user_command(self, listuser):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		# 获取table对象
		tableelem = self.getElem.find_element_with_wait_EC("id", "user_table")
		self.check_common(tableelem, listuser)

	u'''勾选资源
	   parameter:
		   - listresource:资源集合
	'''
	def check_resource_command(self, listresource):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		# 获取table对象
		tableelem = self.getElem.find_element_with_wait_EC("id", "resourceTable")
		self.check_common(tableelem, listresource)

	u'''勾选用户或者资源公共方法
	   parameter:
		   - tableelem:表属性对象
		   - lists:用户集合
	'''
	def check_common(self, tableelem, lists):
		# 获取table对象下的所有tr
		trelems = tableelem.find_elements_by_tag_name("tr")
		# 位于第几行
		line = 0

		# 循环所有tr
		for trelem in trelems:
			line += 1
			# 找到tr下所有td对象
			tds = trelem.find_elements_by_tag_name("td")
			# 获取td[2]的文本
			tdtext = tds[1].text
			for user in lists.split():
				if tdtext == user:
					xpath = "/html/body/div[3]/div[2]/table/tbody/tr[" + str(line) + "]/td[1]/li/input"
					self.getElem.find_element_wait_and_click_EC("xpath", xpath)
					break

	u'''勾选用户组
	   parameter:
		   - listuser:用户集合
	'''
	def check_usergroup_command(self, usergroups):
		self.check_group_common("userGroup_1_switch", "userGroup", usergroups, "userGroup_")

	u'''勾选资源组
	   parameter:
		   - listuser:用户集合
	'''
	def check_regroup_command(self, regroups):
		self.check_group_common("resourceGroup_1_switch", "resourceGroup", regroups, "resourceGroup_")

	u'''勾选组的公共方法
	   parameter:
		   - extendid:闭合按钮的id属性
		   - ulid:ul的id属性
		   - groups:组集合
		   - idfirst:span标签的id属性数字前面的字符
	'''
	def check_group_common(self, extendid, ulid, groups, idfirst):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_click_EC("id", extendid)
		# 获取ul对象
		ulelem = self.getElem.find_element_with_wait_EC("id", ulid)
		# 获取ul对象下的所有a
		aelems = ulelem.find_elements_by_tag_name("a")

		for elem in aelems:
			#获取tr的title属性
			atext = elem.get_attribute("title")
			for usergrop in groups.split():
				if atext == usergrop:
					#获取tr的id属性
					aid = elem.get_attribute("id")
					spanid = idfirst + filter(str.isdigit, aid) + "_check"
					self.getElem.find_element_wait_and_click_EC("id", spanid)
					break

	u'''点击操作的公共方法
	   parameter:
		   - value:序号
		   - statu:代表点击的操作,1代表勾选复选框;2代表状态开关;3代表上移;4代表下移;5代表插入;6代表编辑
	'''
	def click_action_public_command(self, value, status):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		valu = self.cnEn.is_float(value)
		statu = self.cnEn.is_float(status)
		# 获取table对象
		tableelem = self.getElem.find_element_with_wait_EC("id", "content_table")
		# 获取table对象下的所有tr
		trelems = tableelem.find_elements_by_tag_name("tr")
		# 位于第几行
		line = 0

		# 循环所有tr
		for trelem in trelems:
			line += 1
			# 找到tr下所有td对象
			tds = trelem.find_elements_by_tag_name("td")
			# 获取td[2]的文本
			tdtext = tds[1].text

			if tdtext == valu:
				#勾选复选框
				if statu == '1':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[1]/input[1]"
				#状态开关
				elif statu == '2':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[8]/input[1]"
				#上移
				elif statu == '3':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[1]"
				#下移
				elif statu == '4':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[2]"
				#插入
				elif statu == '5':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[3]"
				#编辑
				elif statu == '6':
					xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[4]"
				self.getElem.find_element_wait_and_click_EC("xpath", xpath)
				break

	u'''点击消息提示'''
	def click_message_prompt(self):
		self.frameElem.from_frame_to_otherFrame('topFrame')
		self.getElem.find_element_wait_and_click_EC("id", "link_tc")

	u'''点击消息详情'''
	def click_message_detail(self):
		self.frameElem.from_frame_to_otherFrame('topFrame')
		time.sleep(3)
		self.click_message_prompt()
		time.sleep(2)
		ulselem = self.getElem.find_element_with_wait_EC("id", "digest")
		# 找到ul下所有a对象
		aselems = ulselem.find_elements_by_tag_name("a")
		aselems[0].click()

	u'''选择审批用户
	   parameter:
		   - username:审批用户名称
	'''
	def select_approval_user(self, username):
		self.frameElem.from_frame_to_otherFrame('artIframe')
		name = self.cnEn.is_float(username)
		elem = self.getElem.find_element_with_wait_EC("id", "fortApproverId")
		self.selectElem.select_element_by_visible_text(elem, name)

	u'''填写口令
	   Parameters:
            - pwd:口令
	'''
	def set_passwd(self, pwd):
		passwd = self.cnEn.is_float(pwd)
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_clear("id", "password")
		self.getElem.find_element_wait_and_sendkeys("id", "password", passwd)

	u'''填写备注信息
	   Parameters:
            - descrip:备注信息
	'''
	def set_descrip(self, descrip):
		description = self.cnEn.is_float(descrip)
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_clear("id", "fortDescription")
		self.getElem.find_element_wait_and_sendkeys("id", "fortDescription", description)

	u'''通过消息进行命令审批
	   Parameters:
            - user:用户名称
            - pwd:密码
            - descrip:备注信息
	'''
	def command_by_message_approval(self, user, pwd, descrip):
		self.frameElem.switch_to_content()
		time.sleep(5)
		self.click_message_detail()
		time.sleep(2)
		self.select_approval_user(user)
		time.sleep(1)
		self.set_passwd(pwd)
		self.set_descrip(descrip)
		self.check_sure_button()
		time.sleep(2)

	u'''通过流程控制进行命令审批
	   Parameters:
            - user:用户名称
            - pwd:密码
            - descrip:备注信息
	'''
	def command_by_flow_approval(self, user, pwd, descrip):
		#获取流程号
		number = self.acproval.get_new_process_number()
		self.cmf.select_menu(u"流程控制", u"流程任务")
		self.acproval.click_approval_by_number(number)
		self.select_approval_user(user)
		self.set_passwd(pwd)
		self.set_descrip(descrip)
		self.check_sure_button()

	u'''根据浏览器类型进行单点登录'''
	def choice_browser_open(self,iconType,username,pwd,cmdList):
		fileList = fileRead().get_ip_address()
		browserType = fileList[1].strip('\n')
		if browserType == '1':
			time.sleep(5)
			self.ssoElem.execute_chrome_key()
		elif browserType != '0' or browserType != '1':
			self.ssoElem.opt_cmd("\\testIsomp\\webElement\\sso\\sso_firefox.exe","", "","","")
		time.sleep(3)
		self.ssoElem.opt_cmd("\\testIsomp\\webElement\\rule\\sso_command_open.exe",iconType, username,pwd,cmdList)

	u'''根据浏览器类型关闭单点登录'''
	def choice_browser_close(self,iconType):
		self.ssoElem.opt_cmd("\\testIsomp\\webElement\\rule\\sso_command_close.exe",iconType,"","","")

	u'''命令审批单点登录'''
	def sso_command(self, data):
		time.sleep(2)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.ssoElem.select_account(data[2],data[3])
		self.click_sso_icon(data[2])
		if data[4] != "":
			self.ssoElem.select_protocol(data[4])
		time.sleep(5)
		SendKeys.SendKeys(str(data[5]))
		SendKeys.SendKeys('\n', with_newlines=True)
		time.sleep(2)

	u'''点击单点登录图标
		parameters :
			rename : 资源名称
	'''
	def click_sso_icon(self, rename):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		rname = self.cnEn.is_float(rename)
		row = self.acproval.select_resoure_sso(rname)
		xpath = "/html/body/div[1]/div[7]/div[2]/div/table/tbody/tr[" + str(
			row * 2) + "]/td/div/table/tbody/tr/td[2]/a/img"
		time.sleep(2)
		self.getElem.find_element_wait_and_click_EC("xpath", xpath)
		time.sleep(2)
class RetimeRule(object):
	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.cnEn = cnEncode()
		self.acproval = Accapproval(driver)
		self.command = CommandRule(driver)
		self.log = log()

	u'''点击删除'''
	def click_bulkdel_retime(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "delete_rule_time_resource")

	u'''选择默认动作
		Parameters:
			- staut:0代表禁止登录,1代表允许登录
	'''
	def select_default_type(self, state):
		try:
			valu = self.cnEn.is_float(state)
			self.frameElem.from_frame_to_otherFrame("rigthFrame")
			selem = self.getElem.find_element_with_wait_EC("id", "defaultType")
			self.selectElem.select_element_by_value(selem, valu)
		except Exception:
			print("Select default action failure")

	u'''点击运行状态'''
	def click_running_state(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "ruleState")

	u'''填写每月开始日期
		Parameters:
			- starttime:每月的开始时间
	'''
	def set_month_start_time(self, starttime):
		valu = self.cnEn.is_float(starttime)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_clear_EC("id", "fortMonthStartTime")
		self.getElem.find_element_wait_and_sendkeys("id", "fortMonthStartTime", valu)

	u'''填写每月结束日期
		Parameters:
			- endtime:每月的结束时间
	'''
	def set_month_end_time(self, endtime):
		valu = self.cnEn.is_float(endtime)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_clear_EC("id", "fortMonthEndTime")
		self.getElem.find_element_wait_and_sendkeys("id", "fortMonthEndTime", valu)

	u'''选择每周开始日期
		Parameters:
			- starttime:每周的开始时间
	'''
	def set_week_start_time(self, starttime):
		valu = self.cnEn.is_float(starttime)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		selem = self.getElem.find_element_with_wait_EC("id", "fortWeekStartTime")
		self.selectElem.select_element_by_value(selem, valu)

	u'''选择每周结束日期
		Parameters:
			- endtime:每周的结束时间
	'''
	def set_week_end_time(self, endtime):
		valu = self.cnEn.is_float(endtime)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		selem = self.getElem.find_element_with_wait_EC("id", "fortWeekEndTime")
		self.selectElem.select_element_by_value(selem, valu)

	u'''填写每天开始时间
		Parameters:
			- starttime:每天的开始时间
	'''
	def set_day_start_time(self, starttime):
		valu = self.cnEn.is_float(starttime)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_clear_EC("id", "fortDayStartTime")
		self.getElem.find_element_wait_and_sendkeys("id", "fortDayStartTime", valu)

	u'''填写每天结束时间
		Parameters:
			- endtime:每天的结束时间
	'''
	def set_day_end_time(self, endtime):
		valu = self.cnEn.is_float(endtime)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_clear_EC("id", "fortDayEndTime")
		self.getElem.find_element_wait_and_sendkeys("id", "fortDayEndTime", valu)

	u'''选择动作
		Parameters:
			- staut:0代表禁止登录,1代表允许登录
	'''
	def select_action(self, state):
		valu = self.cnEn.is_float(state)
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		if valu == '1':
			self.getElem.find_element_wait_and_click_EC("id", "ruleTypePass")
		elif valu == '0':
			self.getElem.find_element_wait_and_click_EC("id", "ruleTypeDeny")

	u'''点击保存'''
	def click_save_retime(self):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		self.getElem.find_element_wait_and_click_EC("id", "save_rule_time")

	u'''填写检索的资源名称
		Parameters:
			- rename:资源名称
	'''
	def set_query_rename(self, rename):
		resname = self.cnEn.is_float(rename)
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.getElem.find_element_wait_and_clear_EC("id", "fortResourceName")
		self.getElem.find_element_wait_and_sendkeys("id", "fortResourceName", resname)

	u'''勾选某个资源
		Parameters:
			- rename:资源名称
	'''
	def check_resource(self, rename):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		self.set_query_rename(rename)
		self.command.click_check_resource()
		self.getElem.find_element_wait_and_click_EC("id", "resource_check_all")
		self.command.check_sure_button()

	u'''点击操作的公共方法
		parameter:
			- value:序号
			- statu:代表点击的操作,1代表勾选复选框;2代表上移;3代表下移;4代表插入;5代表编辑
	'''
	def click_option_method(self, value, status):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		valu = self.cnEn.is_float(value)
		statu = self.cnEn.is_float(status)
		# 获取table对象
		tableelem = self.getElem.find_element_with_wait_EC("id", "content_table")
		# 获取table对象下的所有tr
		trelems = tableelem.find_elements_by_tag_name("tr")
		# 位于第几行
		line = 0

		# 循环所有tr
		for trelem in trelems:
			line += 1
			# 找到tr下所有td对象
			tds = trelem.find_elements_by_tag_name("td")
			# 获取td[2]的文本
			tdtext = tds[1].text

			if tdtext == valu:
				#勾选复选框
				if statu == '1':
					xpath = ".//*[@id='content_table']/tbody/tr[" + str(line) + "]/td[1]/input[1]"
				#上移
				elif statu == '2':
					xpath = ".//*[@id='content_table']/tbody/tr[" + str(line) + "]/td[8]/a[1]"
				#下移
				elif statu == '3':
					xpath = ".//*[@id='content_table']/tbody/tr[" + str(line) + "]/td[8]/a[2]"
				#插入
				elif statu == '4':
					xpath = ".//*[@id='content_table']/tbody/tr[" + str(line) + "]/td[8]/a[3]"
				#编辑
				elif statu == '5':
					xpath = ".//*[@id='content_table']/tbody/tr[" + str(line) + "]/td[8]/a[4]"

				self.getElem.find_element_wait_and_click_EC("xpath", xpath)
				break

	u'''校验资源时间规则结果
		parameter:
			- data:数据集
	'''
	def check_resource_time_rule(self, data):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		row = self.acproval.select_resoure_sso(data[1])
		xpath = "//*[@id='content_table']/tbody/tr[" + str(row*2) + "]/td/div/table/tbody/tr/td[2]/a[1]/img"
		isExsit = self.getElem.is_element_exsit("xpath", xpath)
		if isExsit == True:
			self.log.log_detail(data[0], True)
		else:
			self.log.log_detail(data[0], True)
class RetimeRule(object):
    def __init__(self, driver):
        self.driver = driver
        self.getElem = getElement(driver)
        self.selectElem = selectElement(driver)
        self.frameElem = frameElement(driver)
        self.cnEn = cnEncode()
        self.acproval = Accapproval(driver)
        self.command = CommandRule(driver)
        self.log = log()

    u'''点击删除'''

    def click_bulkdel_retime(self):
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        self.getElem.find_element_wait_and_click_EC(
            "id", "delete_rule_time_resource")

    u'''选择默认动作
		Parameters:
			- staut:0代表禁止登录,1代表允许登录
	'''

    def select_default_type(self, state):
        try:
            valu = self.cnEn.is_float(state)
            self.frameElem.from_frame_to_otherFrame("rigthFrame")
            selem = self.getElem.find_element_with_wait_EC("id", "defaultType")
            self.selectElem.select_element_by_value(selem, valu)
        except Exception:
            print("Select default action failure")

    u'''点击运行状态'''

    def click_running_state(self):
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        self.getElem.find_element_wait_and_click_EC("id", "ruleState")

    u'''填写每月开始日期
		Parameters:
			- starttime:每月的开始时间
	'''

    def set_month_start_time(self, starttime):
        valu = self.cnEn.is_float(starttime)
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        self.getElem.find_element_wait_and_clear_EC("id", "fortMonthStartTime")
        self.getElem.find_element_wait_and_sendkeys("id", "fortMonthStartTime",
                                                    valu)

    u'''填写每月结束日期
		Parameters:
			- endtime:每月的结束时间
	'''

    def set_month_end_time(self, endtime):
        valu = self.cnEn.is_float(endtime)
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        self.getElem.find_element_wait_and_clear_EC("id", "fortMonthEndTime")
        self.getElem.find_element_wait_and_sendkeys("id", "fortMonthEndTime",
                                                    valu)

    u'''选择每周开始日期
		Parameters:
			- starttime:每周的开始时间
	'''

    def set_week_start_time(self, starttime):
        valu = self.cnEn.is_float(starttime)
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        selem = self.getElem.find_element_with_wait_EC("id",
                                                       "fortWeekStartTime")
        self.selectElem.select_element_by_value(selem, valu)

    u'''选择每周结束日期
		Parameters:
			- endtime:每周的结束时间
	'''

    def set_week_end_time(self, endtime):
        valu = self.cnEn.is_float(endtime)
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        selem = self.getElem.find_element_with_wait_EC("id", "fortWeekEndTime")
        self.selectElem.select_element_by_value(selem, valu)

    u'''填写每天开始时间
		Parameters:
			- starttime:每天的开始时间
	'''

    def set_day_start_time(self, starttime):
        valu = self.cnEn.is_float(starttime)
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        self.getElem.find_element_wait_and_clear_EC("id", "fortDayStartTime")
        self.getElem.find_element_wait_and_sendkeys("id", "fortDayStartTime",
                                                    valu)

    u'''填写每天结束时间
		Parameters:
			- endtime:每天的结束时间
	'''

    def set_day_end_time(self, endtime):
        valu = self.cnEn.is_float(endtime)
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        self.getElem.find_element_wait_and_clear_EC("id", "fortDayEndTime")
        self.getElem.find_element_wait_and_sendkeys("id", "fortDayEndTime",
                                                    valu)

    u'''选择动作
		Parameters:
			- staut:0代表禁止登录,1代表允许登录
	'''

    def select_action(self, state):
        valu = self.cnEn.is_float(state)
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        if valu == '1':
            self.getElem.find_element_wait_and_click_EC("id", "ruleTypePass")
        elif valu == '0':
            self.getElem.find_element_wait_and_click_EC("id", "ruleTypeDeny")

    u'''点击保存'''

    def click_save_retime(self):
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        self.getElem.find_element_wait_and_click_EC("id", "save_rule_time")

    u'''填写检索的资源名称
		Parameters:
			- rename:资源名称
	'''

    def set_query_rename(self, rename):
        resname = self.cnEn.is_float(rename)
        self.frameElem.from_frame_to_otherFrame("artIframe")
        self.getElem.find_element_wait_and_clear_EC("id", "fortResourceName")
        self.getElem.find_element_wait_and_sendkeys("id", "fortResourceName",
                                                    resname)

    u'''勾选某个资源
		Parameters:
			- rename:资源名称
	'''

    def check_resource(self, rename):
        self.frameElem.from_frame_to_otherFrame("artIframe")
        self.set_query_rename(rename)
        self.command.click_check_resource()
        self.getElem.find_element_wait_and_click_EC("id", "resource_check_all")
        self.command.check_sure_button()

    u'''点击操作的公共方法
		parameter:
			- value:序号
			- statu:代表点击的操作,1代表勾选复选框;2代表上移;3代表下移;4代表插入;5代表编辑
	'''

    def click_option_method(self, value, status):
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        valu = self.cnEn.is_float(value)
        statu = self.cnEn.is_float(status)
        # 获取table对象
        tableelem = self.getElem.find_element_with_wait_EC(
            "id", "content_table")
        # 获取table对象下的所有tr
        trelems = tableelem.find_elements_by_tag_name("tr")
        # 位于第几行
        line = 0

        # 循环所有tr
        for trelem in trelems:
            line += 1
            # 找到tr下所有td对象
            tds = trelem.find_elements_by_tag_name("td")
            # 获取td[2]的文本
            tdtext = tds[1].text

            if tdtext == valu:
                #勾选复选框
                if statu == '1':
                    xpath = ".//*[@id='content_table']/tbody/tr[" + str(
                        line) + "]/td[1]/input[1]"
                #上移
                elif statu == '2':
                    xpath = ".//*[@id='content_table']/tbody/tr[" + str(
                        line) + "]/td[8]/a[1]"
                #下移
                elif statu == '3':
                    xpath = ".//*[@id='content_table']/tbody/tr[" + str(
                        line) + "]/td[8]/a[2]"
                #插入
                elif statu == '4':
                    xpath = ".//*[@id='content_table']/tbody/tr[" + str(
                        line) + "]/td[8]/a[3]"
                #编辑
                elif statu == '5':
                    xpath = ".//*[@id='content_table']/tbody/tr[" + str(
                        line) + "]/td[8]/a[4]"

                self.getElem.find_element_wait_and_click_EC("xpath", xpath)
                break

    u'''校验资源时间规则结果
		parameter:
			- data:数据集
	'''

    def check_resource_time_rule(self, data):
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        row = self.acproval.select_resoure_sso(data[1])
        xpath = "//*[@id='content_table']/tbody/tr[" + str(
            row * 2) + "]/td/div/table/tbody/tr/td[2]/a[1]/img"
        isExsit = self.getElem.is_element_exsit("xpath", xpath)
        if isExsit == True:
            self.log.log_detail(data[0], True)
        else:
            self.log.log_detail(data[0], True)
class Dobapproval(object):

	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.cmf = commonFun(driver)
		self.log = log()
		self.cnEn = cnEncode()
		self.depart = Department(driver)
		self.loginElem = loginPage(self.driver)
		self.authElem = AuthorizationPage(self.driver)
		self.acproval = Accapproval(driver)

	u'''点击授权操作列双人授权按钮
        parameters:
            name : 授权名称
    '''
	def click_double_license_button(self, name):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		self.authElem.operate_double_approval(name)

	u'''点击双人审批图标
            parameters :
                rename : 资源名称
    '''
	def click_double_license_icon(self, rename):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		rname = self.cnEn.is_float(rename)
		row = self.acproval.select_resoure_sso(rname)
		xpath = "/html/body/div[1]/div[7]/div[2]/div/table/tbody/tr[" + str(
			row * 2) + "]/td/div/table/tbody/tr/td[2]/a/img"
		time.sleep(2)
		self.getElem.find_element_wait_and_click_EC("xpath", xpath)
		time.sleep(2)

	u'''校验图标
	   parameters :
            - rename:资源名称
	'''
	def check_ico_len(self, rename):
		self.frameElem.from_frame_to_otherFrame("rigthFrame")
		time.sleep(3)
		row = self.acproval.select_resoure_sso(rename)
		self.acproval.click_refresh_icon(rename)
		ico_xpath = "/html/body/div[1]/div[7]/div[2]/div[1]/table/tbody/tr[" + str(
			row * 2) + "]/td/div/table/tbody/tr/td[2]"
		time.sleep(2)
		selem = self.getElem.find_element_with_wait_EC("xpath", ico_xpath)
		selems = selem.find_elements_by_tag_name("a")
		lengh = len(selems)
		if lengh > 1:
			self.log.log_detail(u"双人授权已同意申请,可以进行单点登录", True)
		else:
			self.log.log_detail(u"双人授权已拒绝申请,不可以进行单点登录", True)

	u'''选择授权人
       parameters :
            - authorizer:授权人名称
    '''
	def select_authorizer(self, authorizer):
		self.frameElem.switch_to_artIframe()
		author = self.cnEn.is_float(authorizer)
		selem = self.getElem.find_element_with_wait_EC("id", "fortApproverId")
		self.selectElem.select_element_by_visible_text(selem, author)

	u'''勾选同终端直接输入口令访问'''
	def check_same_termina(self):
		self.frameElem.switch_to_artIframe()
		self.getElem.find_element_wait_and_click_EC("id", "fortIsRemoteApply")

	u'''填写授权人密码
	   Parameters:
	      - passwd:授权人密码
	'''
	def set_authorizer_pwd(self, passwd):
		self.frameElem.switch_to_artIframe()
		pwd = self.cnEn.is_float(passwd)
		self.getElem.find_element_wait_and_clear("id", "password")
		self.getElem.find_element_wait_and_sendkeys("id", "password", pwd)

	u'''调用新浏览器'''
	def call_other_browsers(self):
		newbrowser = webdriver.Ie()
		# newbrowser = webdriver.Chrome()
		#IE窗口最大化
		newbrowser.maximize_window()
		newbrowser.get("https://172.16.10.155")
		newbrowser.get("javascript:document.getElementById('overridelink').click();")
		return newbrowser

	u'''远程用户登录
	   Parameters:
          - listusers:用户集
	'''
	def user_remote_approval(self, newbrowser, listusers):
		users = listusers.split()
		newbrowser.switch_to_default_content()
		selem = newbrowser.find_element_by_id("loginMethod")
		Select(selem).select_by_value(users[0])
		newbrowser.find_element_by_id("username").click()
		newbrowser.find_element_by_id("username").send_keys(users[1])
		newbrowser.find_element_by_id("pwd").click()
		newbrowser.find_element_by_id("pwd").send_keys(users[2])
		time.sleep(1)
		newbrowser.find_element_by_id("do_login").click()

	u'''菜单选择
        Parameters:
            - newbrowser:新浏览器驱动
            - levelText1:1级菜单文本
            - levelText2:2级菜单文本
            - levelText3:3级菜单文本
    '''
	def click_menu(self,newbrowser, levelText1, levelText2='no',levelText3='no'):

		self.remote_break_frame(newbrowser, "topFrame")
		#点击一级菜单
		newbrowser.find_element_by_link_text(levelText1).click()
		time.sleep(1)
		#如果有2级菜单,再点击2级菜单
		if levelText2 != 'no':
			newbrowser.find_element_by_link_text(levelText2).click()
		#如果有3级菜单,根据名称点击3级菜单
		if levelText3 != 'no':
			self.remote_break_frame(newbrowser, "leftFrame")
			newbrowser.find_element_by_link_text(levelText3).click()

	u'''判断名称是否存在
       Parameters:
          - namevalue:传入的要被查询名称
          - name:表格列的name属性
       return:true代表存在,false代表不存在
    '''
	def namevalue_remote_is_exsit(self, newbrowser,namevalue, name):
		nameval = self.cnEn.is_float(namevalue)
		namesex = self.cnEn.is_float(name)
		isExsit = False
		text_list = newbrowser.find_elements_by_name(namesex)
		for fortNameValue in text_list:
			fortNameValue_text = fortNameValue.text
			if fortNameValue_text == nameval:
				isExsit = True
				break
		return isExsit

	u'''查询已存在名称位于第几行
       Parameters:
          - namevalue:传入的要被查询名称
          - name:表格列的name属性
       return:定位该名称位于第几行
    '''
	def find_name_remote_by_row(self, newbrowser, namevalue, name):
		self.remote_break_frame(newbrowser, "mainFrame")
		nameval = self.cnEn.is_float(namevalue)
		namesex = self.cnEn.is_float(name)
		row = 0
		if self.namevalue_remote_is_exsit(newbrowser,nameval, namesex):
			text_list = newbrowser.find_elements_by_name(namesex)
			for fortNameValue in text_list:
				row = row + 1
				fortNameValue_text = fortNameValue.text
				if fortNameValue_text == nameval:
					break
		return row

	u'''通过流程号点击要审批的信息
	   Parameters:
          - number:流程号
	'''
	def click_remote_approval_by_number(self, newbrowser, number):
		row = self.find_name_remote_by_row(newbrowser, number, "fortProcessInstanceId")
		xpath = "/html/body/form/div/div[7]/div[2]/div/table/tbody/tr[" + str(row) + "]/td[8]/input[1]"
		newbrowser.find_element_by_xpath(xpath).click()

	u'''流程控制是否同意审批
	   Parameters:
          - status:1代表同意审批,2代表拒绝审批
	'''
	def process_remote_is_agree_approval(self, newbrowser, status):
		statu = self.cnEn.is_float(status)
		self.remote_break_frame(newbrowser, "mainFrame")
		if statu == '1':
			newbrowser.find_element_by_id("yes").click()
		elif statu == '2':
			newbrowser.find_element_by_id("no").click()

	u'''填写流程控制中审批申请单的描述
	   Parameters:
          - description:描述内容
	'''
	def set_process_remote_description(self, newbrowser, description):
		descri = self.cnEn.is_float(description)
		self.remote_break_frame(newbrowser, "mainFrame")
		newbrowser.find_element_by_id("fortApprovalOpinions").clear()
		newbrowser.find_element_by_id("fortApprovalOpinions").send_keys(descri)

	u'''点击提交按钮'''
	def click_remote_submit(self, newbrowser):
		self.remote_break_frame(newbrowser, "mainFrame")
		newbrowser.find_element_by_id("save_process_approval").click()

	u'''点击确定按钮'''
	def click_remote_msg_button(self, newbrowser):
		newbrowser.switch_to_default_content()
		OKBTN = "//div[@id='aui_buttons']/button[1]"
		newbrowser.find_element_by_xpath(OKBTN).click()

	u'''点击返回按钮'''
	def remote_back(self, newbrowser):
		self.remote_break_frame(newbrowser, "mainFrame")
		newbrowser.find_element_by_id("history_skip").click()

	u'''跳转frame
	   Parameters:
            - frameName:要跳转到的frame的名字
	'''
	def remote_break_frame(self, newbrowser, frameName):
		newbrowser.switch_to_default_content()
		newbrowser.switch_to_frame("content1")
		newbrowser.switch_to_frame(frameName)

	u'''点击退出'''
	def remote_quit(self,newbrowser):
		self.remote_break_frame(newbrowser, "topFrame")
		time.sleep(1)
		newbrowser.find_element_by_id("logout").click()

	u'''申请人发送双人审批申请
	   Parameters:
          - data:excel中的一行数据
	'''
	def send_double_license_applicant(self, data):
		self.acproval.select_resoure_account(data[1], data[2])
		self.click_double_license_icon(data[1])
		self.select_authorizer(data[3])
		if data[4] != 'no':
			self.check_same_termina()
			self.set_authorizer_pwd(data[4])
		self.acproval.set_operation_description(data[5])
		self.acproval.click_sure_button()
		self.driver.implicitly_wait(10)
		self.log.log_detail(data[0], True)

	u'''审批人通过当前浏览器流程控制进行审批
	   Parameters:
          - number:流程号
	'''
	def approver_by_process_approval(self, expData, number):

		xpathMsg = ".//*[@id='body1']/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(expData)):
			data = expData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					self.acproval.user_login(data[2])
					self.frameElem.from_frame_to_otherFrame("topFrame")
					self.cmf.select_menu(u"流程控制", u"流程任务")
					self.acproval.click_approval_by_number(number)
					if data[1] != 'no':
						self.frameElem.switch_to_content()
						self.cmf.test_win_check_point("xpath", xpathMsg, data, flag)
					else:
						self.acproval.process_is_agree_approval(data[3])
						self.acproval.set_process_apply_description(data[4])
						self.acproval.click_submit()
						self.cmf.click_login_msg_button()
					self.acproval.back_quit_common()
			except Exception as e:
				print ("expired_approvel fail:" + str(e))

	u'''审批人通过新开启的浏览器流程控制进行审批
	   Parameters:
          - number:流程号
	'''
	def approver_remote_approval(self, expData, number):
		for dataRow in range(len(expData)):
			data = expData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					newbrowser = self.call_other_browsers()
					self.user_remote_approval(newbrowser, data[1])
					self.click_menu(newbrowser, u"流程控制", u"流程任务")
					self.click_remote_approval_by_number(newbrowser, number)
					self.process_remote_is_agree_approval(newbrowser, data[2])
					self.set_process_remote_description(newbrowser, data[3])
					self.click_remote_submit(newbrowser)
					self.click_remote_msg_button(newbrowser)
					self.remote_back(newbrowser)
					self.driver.implicitly_wait(5)
					self.remote_quit(newbrowser)
					newbrowser.quit()
			except Exception as e:
				print ("expired_approvel fail:" + str(e))