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))
class testAccapproval(object):
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.data = dataFileName()
        self.cmf = commonFun(driver)
        self.acproval = Accapproval(driver)
        self.loginElem = loginPage(self.driver)
        self.authElem = AuthorizationPage(self.driver)
        self.flow = Flowcontrol(self.driver)

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

    def get_accapproval_data(self, sheetname):
        dataFile = dataFileName()
        acpPath = dataFile.get_accapproval_test_data_url()
        acpData = dataFile.get_data(acpPath, sheetname)
        return acpData

    u'''添加访问审批'''

    def add_access_approvel_001(self):
        #日志开始记录
        self.log.log_start("add_access_approvel")
        #获取访问审批的数据
        acpData = self.get_accapproval_data("add_access_approvel")
        for dataRow in range(len(acpData)):
            data = acpData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    if dataRow == 1:
                        self.acproval.click_access_approval_button(data[2])
                        #设置开关状态
                        self.authElem.set_switch_on()
                    self.authElem.click_add_approval_level()
                    self.authElem.click_add_approval(data[3])
                    #添加审批人
                    self.authElem.set_select_user_search_button()
                    self.acproval.check_user(data[4])
                    self.authElem.set_ok_button()
                    #设置审批级别中的通过审批人个数
                    self.acproval.select_approval_num(data[3], data[5])
            except Exception as e:
                print("add_access_approvell fail: ") + str(e)

        self.log.log_detail(u"添加访问审批成功", True)
        #点击保存
        self.authElem.approval_save_button()
        self.cmf.click_login_msg_button()
        #点击返回
        self.authElem.approval_back_button()
        self.log.log_end("add_access_approvel")

    u'''访问审批通过流程控制拒绝审批'''

    def access_deny_approvel_002(self):
        #日志开始记录
        self.log.log_start("access_deny_approvel")
        #获取访问审批申请的数据
        appData = self.get_accapproval_data("access_approvel_sso")
        #获取访问审批审批的数据
        acpData = self.get_accapproval_data("deny_approvel")

        for dataRow in range(len(appData)):
            data = appData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    list = [data[9], data[10], data[11], data[12], data[13]]
                    self.loginElem.quit()
                    self.loginElem.login(list)
                    self.cmf.select_role_by_text(u"运维操作员")
                    self.acproval.send_access_approval_applicant(data)
                    number = self.acproval.get_new_process_number()
                    self.loginElem.quit()
                    self.acproval.approval_by_approver(acpData, number)
            except Exception as e:
                print("access_deny_approvel fail: ") + str(e)
        self.log.log_end("access_deny_approvel")

    u'''访问审批通过流程控制同意审批'''

    def access_agree_approvel_003(self):
        #日志开始记录
        self.log.log_start("access_agree_approvel")
        #获取访问审批申请的数据
        appData = self.get_accapproval_data("access_approvel_sso")
        #获取访问审批审批的数据
        acpData = self.get_accapproval_data("agree_approvel")

        for dataRow in range(len(appData)):
            data = appData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    list = [data[9], data[10], data[11], data[12], data[13]]
                    self.loginElem.login(list)
                    self.cmf.select_role_by_text(u"运维操作员")
                    self.acproval.send_access_approval_applicant(data)
                    number = self.acproval.get_new_process_number()
                    self.loginElem.quit()
                    self.acproval.approval_by_approver(acpData, number)
            except Exception as e:
                print("access_agree_approvel fail: ") + str(e)
        self.log.log_end("access_agree_approvel")

    u'''紧急运维通过流程控制拒绝审批'''

    def urgent_deny_approvel_004(self):
        #日志开始记录
        self.log.log_start("urgent_deny_approvel")
        #获取访问审批申请的数据
        appData = self.get_accapproval_data("urgent_approvel")
        #获取访问审批审批的数据
        acpData = self.get_accapproval_data("deny_approvel")

        for dataRow in range(len(appData)):
            data = appData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    list = [data[4], data[5], data[6], data[7], data[8]]
                    self.loginElem.login(list)
                    self.cmf.select_role_by_text(u"运维操作员")
                    self.acproval.send_urgent_operation_applicant(data)
                    number = self.acproval.get_new_process_number()
                    self.loginElem.quit()
                    self.acproval.approval_by_approver(acpData, number)
            except Exception as e:
                print("urgent_deny_approvel fail: ") + str(e)
        self.log.log_end("urgent_deny_approvel")

    u'''紧急运维通过流程控制同意审批'''

    def urgent_agree_approvel_005(self):

        #日志开始记录
        self.log.log_start("urgent_agree_approvel")
        #获取访问审批申请的数据
        appData = self.get_accapproval_data("urgent_approvel")
        #获取访问审批审批的数据
        acpData = self.get_accapproval_data("agree_urgent")

        for dataRow in range(len(appData)):
            data = appData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    list = [data[4], data[5], data[6], data[7], data[8]]
                    self.loginElem.login(list)
                    self.cmf.select_role_by_text(u"运维操作员")
                    self.acproval.send_urgent_operation_applicant(data)
                    number = self.acproval.get_new_process_number()
                    self.loginElem.quit()
                    self.acproval.approval_by_approver(acpData, number)
            except Exception as e:
                print("urgent_agree_approvel fail: ") + str(e)
        self.log.log_end("urgent_agree_approvel")

    u'''访问审批流程任务查询'''

    def access_query_process_task_006(self):
        #日志开始记录
        self.log.log_start("access_query_process_task")
        #获取流程任务查询的数据
        taskData = self.get_accapproval_data("process_task")

        for dataRow in range(len(taskData)):
            data = taskData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    if dataRow == 1:
                        self.acproval.user_login(data[1])
                    self.flow.query_process_task(data)
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("access_query_process_task fail: ") + str(e)
        self.log.log_end("access_query_process_task")

    u'''访问审批个人历史查询'''

    def access_query_personal_history_007(self):
        #日志开始记录
        self.log.log_start("access_query_personal_history")
        #获取个人历史查询的数据
        perData = self.get_accapproval_data("personal_history")

        for dataRow in range(len(perData)):
            data = perData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    self.flow.query_personal_history(data)
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("access_query_personal_history fail: ") + str(e)
        self.loginElem.quit()
        self.log.log_end("access_query_personal_history")

    u'''访问审批申请历史查询'''

    def access_query_apply_history_008(self):
        #日志开始记录
        self.log.log_start("access_query_apply_history")
        #获取申请历史查询的数据
        applyData = self.get_accapproval_data("apply_history")

        for dataRow in range(len(applyData)):
            data = applyData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    if dataRow == 1:
                        self.acproval.user_login(data[9])
                    self.flow.query_apply_history(data)
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("access_query_apply_history fail: ") + str(e)
        self.loginElem.quit()
        self.log.log_end("access_query_apply_history")

    u'''访问审批全部历史查询'''

    def access_query_all_history_009(self):
        #日志开始记录
        self.log.log_start("access_query_all_history")
        #获取全部历史查询的数据
        allData = self.get_accapproval_data("all_history")

        for dataRow in range(len(allData)):
            data = allData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    if dataRow == 1:
                        self.acproval.user_login(data[1])
                    self.flow.query_all_history(data)
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("access_query_all_history fail: ") + str(e)
        self.log.log_end("access_query_all_history")
class testAccapproval(object):

	def __init__(self, driver):
		self.driver = driver
		self.log = log()
		self.data = dataFileName()
		self.cmf = commonFun(driver)
		self.acproval = Accapproval(driver)
		self.comsuit = CommonSuiteData(self.driver)
		self.loginElem = loginPage(self.driver)
		self.authElem = AuthorizationPage(self.driver)
		self.flow = Flowcontrol(self.driver)

	u'''获取测试数据
	   Parameters:
	      - sheetname:sheet名称
	   return:表格数据
	'''
	def get_accapproval_data(self, sheetname):
		dataFile = dataFileName()
		acpPath = dataFile.get_accapproval_test_data_url()
		acpData = dataFile.get_data(acpPath, sheetname)
		return acpData

	u'''添加访问审批'''
	def add_access_approvel_001(self):
		#日志开始记录
		self.log.log_start("add_access_approvel")
		#获取访问审批的数据
		acpData = self.get_accapproval_data("add_access_approvel")
		for dataRow in range(len(acpData)):
			data = acpData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					if dataRow == 1:
						self.acproval.click_access_approval_button(data[2])
						#设置开关状态
						self.authElem.set_switch_on()
					self.authElem.click_add_approval_level()
					self.authElem.click_add_approval(data[3])
					#添加审批人
					self.authElem.set_select_user_search_button()
					self.acproval.check_user(data[4])
					self.authElem.set_ok_button()
					#设置审批级别中的通过审批人个数
					self.acproval.select_approval_num(data[3], data[5])
			except Exception as e:
				print ("add_access_approvell fail: ") + str(e)

		self.log.log_detail(u"添加访问审批成功", True)
		#点击保存
		self.authElem.approval_save_button()
		self.cmf.click_login_msg_button()
		#点击返回
		self.authElem.approval_back_button()
		self.log.log_end("add_access_approvel")

	u'''访问审批通过流程控制拒绝审批'''
	def access_deny_approvel_002(self):

		self.cmf.select_role_by_text(u"运维操作员")
		#日志开始记录
		self.log.log_start("access_deny_approvel")
		#获取访问审批申请的数据
		appData = self.get_accapproval_data("access_approvel_sso")
		#获取访问审批审批的数据
		acpData = self.get_accapproval_data("deny_approvel")

		for dataRow in range(len(appData)):
			data = appData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					self.acproval.send_access_approval_applicant(data)
					number = self.acproval.get_new_process_number()
					self.loginElem.quit()
					self.acproval.approval_by_approver(acpData, number)
			except Exception as e:
				print ("access_deny_approvel fail: ") + str(e)
		self.log.log_end("access_deny_approvel")

	u'''访问审批通过流程控制同意审批'''
	def access_agree_approvel_003(self):

		self.comsuit.use_new_user_login()
		#日志开始记录
		self.log.log_start("access_agree_approvel")
		#获取访问审批申请的数据
		appData = self.get_accapproval_data("access_approvel_sso")
		#获取访问审批审批的数据
		acpData = self.get_accapproval_data("agree_approvel")

		for dataRow in range(len(appData)):
			data = appData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					self.acproval.send_access_approval_applicant(data)
					number = self.acproval.get_new_process_number()
					self.loginElem.quit()
					self.acproval.approval_by_approver(acpData, number)
			except Exception as e:
				print ("access_agree_approvel fail: ") + str(e)
		self.log.log_end("access_agree_approvel")

	u'''紧急运维通过流程控制拒绝审批'''
	def urgent_deny_approvel_004(self):

		self.comsuit.use_new_user_login()
		#日志开始记录
		self.log.log_start("urgent_deny_approvel")
		#获取访问审批申请的数据
		appData = self.get_accapproval_data("urgent_approvel")
		#获取访问审批审批的数据
		acpData = self.get_accapproval_data("deny_approvel")

		for dataRow in range(len(appData)):
			data = appData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					self.acproval.send_urgent_operation_applicant(data)
					number = self.acproval.get_new_process_number()
					self.loginElem.quit()
					self.acproval.approval_by_approver(acpData, number)
			except Exception as e:
				print ("urgent_deny_approvel fail: ") + str(e)
		self.log.log_end("urgent_deny_approvel")

	u'''紧急运维通过流程控制同意审批'''
	def urgent_agree_approvel_005(self):

		self.comsuit.use_new_user_login()
		#日志开始记录
		self.log.log_start("urgent_agree_approvel")
		#获取访问审批申请的数据
		appData = self.get_accapproval_data("urgent_approvel")
		#获取访问审批审批的数据
		acpData = self.get_accapproval_data("agree_urgent")

		for dataRow in range(len(appData)):
			data = appData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					self.acproval.send_urgent_operation_applicant(data)
					number = self.acproval.get_new_process_number()
					self.loginElem.quit()
					self.acproval.approval_by_approver(acpData, number)
			except Exception as e:
				print ("urgent_agree_approvel fail: ") + str(e)
		self.log.log_end("urgent_agree_approvel")

	u'''访问审批流程任务查询'''
	def access_query_process_task_006(self):
		#日志开始记录
		self.log.log_start("access_query_process_task")
		#获取流程任务查询的数据
		taskData = self.get_accapproval_data("process_task")

		for dataRow in range(len(taskData)):
			data = taskData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					if dataRow == 1:
						self.acproval.user_login(data[1])
					self.flow.query_process_task(data)
					self.log.log_detail(data[0], True)
			except Exception as e:
				print ("access_query_process_task fail: ") + str(e)
		self.log.log_end("access_query_process_task")

	u'''访问审批个人历史查询'''
	def access_query_personal_history_007(self):
		#日志开始记录
		self.log.log_start("access_query_personal_history")
		#获取个人历史查询的数据
		perData = self.get_accapproval_data("personal_history")

		for dataRow in range(len(perData)):
			data = perData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					self.flow.query_personal_history(data)
					self.log.log_detail(data[0], True)
			except Exception as e:
				print ("access_query_personal_history fail: ") + str(e)
		self.loginElem.quit()
		self.log.log_end("access_query_personal_history")

	u'''访问审批申请历史查询'''
	def access_query_apply_history_008(self):
		self.comsuit.use_new_user_login()
		#日志开始记录
		self.log.log_start("access_query_apply_history")
		#获取申请历史查询的数据
		applyData = self.get_accapproval_data("apply_history")

		for dataRow in range(len(applyData)):
			data = applyData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					self.flow.query_apply_history(data)
					self.log.log_detail(data[0], True)
			except Exception as e:
				print ("access_query_apply_history fail: ") + str(e)
		self.log.log_end("access_query_apply_history")

	u'''访问审批全部历史查询'''
	def access_query_all_history_009(self):
		self.comsuit.dep_switch_to_sys()
		#日志开始记录
		self.log.log_start("access_query_all_history")
		#获取全部历史查询的数据
		allData = self.get_accapproval_data("all_history")

		for dataRow in range(len(allData)):
			data = allData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					self.flow.query_all_history(data)
					self.log.log_detail(data[0], True)
			except Exception as e:
				print ("access_query_all_history fail: ") + str(e)
		self.log.log_end("access_query_all_history")

	u'''访问审批部门历史查询'''
	def access_query_department_history_010(self):
		self.comsuit.sys_switch_to_dep()
		#日志开始记录
		self.log.log_start("access_query_department_history")
		#获取流程任务查询的数据
		deprtData = self.get_accapproval_data("department_history")

		for dataRow in range(len(deprtData)):
			data = deprtData[dataRow]
			try:
				#如果不是第1行,读取数据
				if dataRow != 0:
					self.flow.query_department_history(data)
					self.log.log_detail(data[0], True)
			except Exception as e:
				print ("access_query_department_history fail: ") + str(e)
		self.log.log_end("access_query_department_history")
class testDobapproval(object):
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.data = dataFileName()
        self.cmf = commonFun(driver)
        self.double = Dobapproval(driver)
        self.comsuit = CommonSuiteData(self.driver)
        self.loginElem = loginPage(self.driver)
        self.authElem = AuthorizationPage(self.driver)
        self.acproval = Accapproval(driver)
        self.flow = Flowcontrol(self.driver)
        self.frameElem = frameElement(self.driver)

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

    def get_double_data(self, sheetname):
        dataFile = dataFileName()
        dobPath = dataFile.get_double_license_test_data_url()
        dobData = dataFile.get_data(dobPath, sheetname)
        return dobData

    u'''添加双人授权'''

    def add_double_license_001(self):
        #日志开始记录
        self.log.log_start("add_double_license")
        #获取双人授权的数据
        dobData = self.get_double_data("add_double_license")
        for dataRow in range(len(dobData)):
            data = dobData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    self.double.click_double_license_button(data[1])
                    self.authElem.click_all_approver()
                    self.authElem.click_all_candidate()
                    self.authElem.click_start_association()
                    self.authElem.click_create_relate()
                    self.cmf.click_login_msg_button()
                    #点击返回
                    self.authElem.click_child_page_back_button()
                    self.log.log_detail(u"添加双人授权成功", True)
            except Exception as e:
                print("add_double_license fail: ") + str(e)

        self.log.log_end("add_double_license")

    u'''双人审批同终端审批'''

    def same_termina_approvel_002(self):

        self.cmf.select_role_by_text(u"运维操作员")
        #日志开始记录
        self.log.log_start("same_termina_approvel")
        #获取双人审批申请的数据
        dobData = self.get_double_data("double_license_sso")

        for dataRow in range(len(dobData)):
            data = dobData[dataRow]
            try:
                #如果是第1行,读取数据
                if dataRow == 1:
                    self.double.send_double_license_applicant(data)
                    self.double.check_ico_len(data[1])
                    self.loginElem.quit()
            except Exception as e:
                print("same_termina_approvel fail: ") + str(e)
        self.log.log_end("same_termina_approvel")

    u'''双人审批申请人已下线审批过期'''

    def termina_expired_approvel_003(self):

        self.comsuit.use_new_user_login()
        #日志开始记录
        self.log.log_start("Expired_approvel")
        #获取双人审批申请的数据
        dobData = self.get_double_data("double_license_sso")
        expData = self.get_double_data("termina_approvel")

        for dataRow in range(len(dobData)):
            data = dobData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow == 2:
                    self.double.send_double_license_applicant(data)
                    number = self.acproval.get_new_process_number()
                    self.loginElem.quit()
                    self.double.approver_by_process_approval(expData, number)
            except Exception as e:
                print("Expired_approvel fail: ") + str(e)
        self.log.log_end("Expired_approvel")

    u'''双人审批审批人拒绝申请'''

    def termina_deny_approvel_004(self):

        self.comsuit.use_new_user_login()
        #日志开始记录
        self.log.log_start("deny_double_approvel")
        #获取双人审批申请的数据
        dobData = self.get_double_data("double_license_sso")
        expData = self.get_double_data("deny_approvel")

        for dataRow in range(len(dobData)):
            data = dobData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow == 2:
                    self.double.send_double_license_applicant(data)
                    number = self.acproval.get_new_process_number()
                    self.double.approver_remote_approval(expData, number)
                    self.cmf.select_menu(u"运维操作", u"SSO")
                    self.double.check_ico_len(data[1])
                    self.loginElem.quit()
            except Exception as e:
                print("deny_double_approvel fail: ") + str(e)
        self.log.log_end("deny_double_approvel")

    u'''双人审批审批人同意申请'''

    def termina_agree_approvel_005(self):

        self.comsuit.use_new_user_login()
        #日志开始记录
        self.log.log_start("agree_double_approvel")
        #获取双人审批申请的数据
        dobData = self.get_double_data("double_license_sso")
        expData = self.get_double_data("agree_approvel")

        for dataRow in range(len(dobData)):
            data = dobData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow == 2:
                    self.double.send_double_license_applicant(data)
                    number = self.acproval.get_new_process_number()
                    self.double.approver_remote_approval(expData, number)
                    self.cmf.select_menu(u"运维操作", u"SSO")
                    self.double.check_ico_len(data[1])
                    self.loginElem.quit()
            except Exception as e:
                print("agree_double_approvel fail: ") + str(e)
        self.log.log_end("agree_double_approvel")

    u'''访问审批流程任务查询'''

    def double_query_process_task_006(self):
        #日志开始记录
        self.log.log_start("double_query_process_task")
        #获取流程任务查询的数据
        taskData = self.get_double_data("process_task")

        for dataRow in range(len(taskData)):
            data = taskData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    if dataRow == 1:
                        self.acproval.user_login(data[1])
                    self.flow.query_process_task(data)
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("double_query_process_task fail: ") + str(e)
        self.log.log_end("double_query_process_task")

    u'''访问审批个人历史查询'''

    def double_query_personal_history_007(self):
        #日志开始记录
        self.log.log_start("double_query_personal_history")
        #获取个人历史查询的数据
        perData = self.get_double_data("personal_history")

        for dataRow in range(len(perData)):
            data = perData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    self.flow.query_personal_history(data)
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("double_query_personal_history fail: ") + str(e)
        self.loginElem.quit()
        self.log.log_end("double_query_personal_history")

    u'''访问审批申请历史查询'''

    def double_query_apply_history_008(self):
        self.comsuit.use_new_user_login()
        #日志开始记录
        self.log.log_start("double_query_apply_history")
        #获取申请历史查询的数据
        applyData = self.get_double_data("apply_history")

        for dataRow in range(len(applyData)):
            data = applyData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    self.flow.query_apply_history(data)
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("double_query_apply_history fail: ") + str(e)
        self.log.log_end("double_query_apply_history")

    u'''访问审批全部历史查询'''

    def double_query_all_history_009(self):
        self.comsuit.dep_switch_to_sys()
        #日志开始记录
        self.log.log_start("double_query_all_history")
        #获取全部历史查询的数据
        allData = self.get_double_data("all_history")

        for dataRow in range(len(allData)):
            data = allData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    self.flow.query_all_history(data)
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("double_query_all_history fail: ") + str(e)
        self.log.log_end("double_query_all_history")

    u'''访问审批部门历史查询'''

    def double_query_department_history_010(self):
        self.comsuit.sys_switch_to_dep()
        #日志开始记录
        self.log.log_start("double_query_department_history")
        #获取流程任务查询的数据
        deprtData = self.get_double_data("department_history")

        for dataRow in range(len(deprtData)):
            data = deprtData[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    self.flow.query_department_history(data)
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("double_query_department_history fail: ") + str(e)
        self.log.log_end("double_query_department_history")
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))