Esempio n. 1
0
 def __init__(self, driver):
     self.driver = driver
     self.dataFile = dataFileName()
     self.cmf = commonFun(self.driver)
     self.initDriver = initDriver()
     self.loginElem = loginPage(self.driver)
     self.roleElem = Role(self.driver)
     self.userElem = UserPage(self.driver)
     self.frameElem = frameElement(self.driver)
     self.authElem = AuthMethodPage(self.driver)
     self.dptment = Department(self.driver)
     self.resource = Resource(self.driver)
     self.account = Accountmgr(self.driver)
     self.windowsElem = WindowsResource(self.driver)
     self.databaseElem = DatabaseResource(self.driver)
     self.usergroup = Usergroup(self.driver)
     self.regroup = Regroup(self.driver)
     self.appElem = AppPage(self.driver)
     self.authorizationElem = AuthorizationPage(self.driver)
     self.testAutho = testAuthorization(self.driver)
     self.clientElem = ClientPage(self.driver)
     self.command = CommandRule(self.driver)
     self.ntp = NtpService(self.driver)
     self.mail = MailPage(self.driver)
     self.syslog = Syslog(driver)
     self.ssoElem = SsoPage(self.driver)
     self.alarm = AlarmPage(self.driver)
     self.PwdStr = PwdStrategy(self.driver)
     self.passwdenvelope = EnvelopePage(self.driver)
 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)
Esempio n. 3
0
 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.loginElem = loginPage(self.driver)
     self.authElem = AuthorizationPage(self.driver)
 def __init__(self, driver):
     self.driver = driver
     self.log = log()
     self.cmf = commonFun(driver)
     self.getElem = getElement(driver)
     self.cnEnde = cnEncode()
     self.authElem = AuthorizationPage(self.driver)
     self.tableElem = tableElement(self.driver)
     self.selectElem = selectElement(driver)
     self.dataFile = dataFileName()
     self.frameElem = frameElement(self.driver)
Esempio n. 5
0
 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)
Esempio n. 6
0
 def __init__(self, driver):
     self.driver = driver
     self.log = log()
     self.cmf = commonFun(driver)
     self.getElem = getElement(driver)
     self.cnEnde = cnEncode()
     self.confReport = ConfReportPage(self.driver)
     self.optReport = OptReportPage(self.driver)
     self.tableElem = tableElement(self.driver)
     self.selectElem = selectElement(driver)
     self.dataFile = dataFileName()
     self.frameElem = frameElement(self.driver)
     self.loginFun = loginPage(self.driver)
     self.commonSuite = CommonSuiteData(self.driver)
     self.authElem = AuthorizationPage(self.driver)
Esempio n. 7
0
	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)
Esempio n. 8
0
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.authElem = AuthorizationPage(self.driver)
		self.tableElem = tableElement(self.driver)
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
	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)
Esempio n. 10
0
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.confReport = ConfReportPage(self.driver)
		self.optReport = OptReportPage(self.driver)
		self.tableElem = tableElement(self.driver)
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
		self.loginFun = loginPage(self.driver)
		self.commonSuite = CommonSuiteData(self.driver)
		self.authElem = AuthorizationPage(self.driver)
Esempio n. 11
0
class Accapproval(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.loginElem = loginPage(self.driver)
        self.authElem = AuthorizationPage(self.driver)

    u'''点击授权操作列访问审批按钮
		parameters:
			name : 授权名称
	'''

    def click_access_approval_button(self, name):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.authElem.operate_access_approval(name)

    u'''勾选用户
	   parameter:
		   - listuser:用户集合
	'''

    def check_user(self, listuser):
        self.frameElem.from_frame_to_otherFrame("artIframe")
        # 获取table对象
        tableelem = self.getElem.find_element_with_wait_EC("id", "user_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
            for user in listuser.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'''设置级别中的审批人个数
		parameters :
		    level : 级别
		    value : option的value值
	'''

    def select_approval_num(self, level, value):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        relevel = self.cnEn.is_float(level)
        revalue = self.cnEn.is_float(value)
        level_xpath = "/html/body/div/div[3]/div[" + relevel + "]/div[3]/select"
        selem = self.getElem.find_element_with_wait_EC('xpath', level_xpath)
        self.selectElem.select_element_by_value(selem, revalue)

    u'''选择进行单点登录的资源并且返回该资源位于第几行
		parameters :
		    rename : 资源名称
		return: row代表资源名称位于第几行
	'''

    def select_resoure_sso(self, rename):
        rname = self.cnEn.is_float(rename)
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        row = self.find_name_by_row(rname, "fortResourceName")
        rename_xpath = "/html/body/div[1]/div[7]/div[2]/div/table/tbody/tr[" + str(
            row * 2 - 1) + "]/td[3]"
        self.getElem.find_element_wait_and_click_EC("xpath", rename_xpath)
        return row

    u'''点击访问审批或紧急运维图标
		parameters :
		    rename : 资源名称
		    statu : 1代表访问审批,2代表紧急运维
	'''

    def click_access_approval_icon(self, rename, statu):
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        rname = self.cnEn.is_float(rename)
        status = self.cnEn.is_float(statu)
        row = self.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[" + str(status) + "]/img"
        time.sleep(2)
        self.getElem.find_element_wait_and_click_EC("xpath", xpath)

    u'''选择进行资源账号
		parameters :
		    rename : 资源名称
		    reactname : 资源账号名称
	'''

    def select_resoure_account(self, rename, reactname):
        rname = self.cnEn.is_float(rename)
        actname = self.cnEn.is_float(reactname)
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        row = self.find_name_by_row(rname, "fortResourceName")
        rename_xpath = "/html/body/div[1]/div[7]/div[2]/div/table/tbody/tr[" + str(
            row * 2 - 1) + "]/td[6]/select"
        selem = self.getElem.find_element_with_wait_EC("xpath", rename_xpath)
        self.selectElem.select_element_by_visible_text(selem, actname)

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

    def namevalue_is_exsit(self, namevalue, name):
        nameval = self.cnEn.is_float(namevalue)
        namesex = self.cnEn.is_float(name)
        isExsit = False
        text_list = self.driver.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_by_row(self, namevalue, name):
        nameval = self.cnEn.is_float(namevalue)
        namesex = self.cnEn.is_float(name)
        row = 0
        if self.namevalue_is_exsit(nameval, namesex):
            text_list = self.driver.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:
			- description:描述内容
	'''

    def set_operation_description(self, description):
        descri = self.cnEn.is_float(description)
        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",
                                                    descri)

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

    def click_sure_button(self):
        self.frameElem.switch_to_content()
        self.getElem.find_element_wait_and_click_EC("id", "okButton")

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

    def click_submit(self):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.getElem.find_element_wait_and_click_EC("id",
                                                    "save_process_approval")

    u'''用户登录
		Parameters:
			- listuser:用户登录集
	'''

    def user_login(self, listuser):
        users = listuser.split()
        self.frameElem.switch_to_content()
        time.sleep(2)
        self.loginElem.set_login_method(users[0])
        self.loginElem.set_login_username(users[1])
        self.loginElem.set_login_pwd(users[2])
        time.sleep(1)
        self.loginElem.click_login_button()

    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_all_message(self):
        self.frameElem.from_frame_to_otherFrame('topFrame')
        self.getElem.find_element_wait_and_click_EC(
            "xpath", "/html/body/div[3]/div/div/div[1]/a")

    u'''通过申请时间点击要审批的信息
		Parameters:
			- applytime:申请时间
	'''

    def click_approval_by_message(self, applytime):
        self.frameElem.from_frame_to_otherFrame('mainFrame')
        row = self.find_name_by_row(applytime, "fortTime")
        xpath = "/html/body/div/div[2]/div[2]/div/table/tbody/tr[" + str(
            row) + "]/td[5]/lable"
        self.getElem.find_element_wait_and_click_EC("xpath", xpath)

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

    def click_approval_by_number(self, number):
        self.frameElem.from_frame_to_otherFrame('mainFrame')
        row = self.find_name_by_row(number, "fortProcessInstanceId")
        xpath = "/html/body/form/div/div[7]/div[2]/div/table/tbody/tr[" + str(
            row) + "]/td[8]/input[1]"
        self.getElem.find_element_wait_and_click_EC("xpath", xpath)

    u'''消息弹框是否同意审批
		Parameters:
			- status:1代表同意审批,2代表拒绝审批
	'''

    def message_is_agree_approval(self, status):
        self.frameElem.from_frame_to_otherFrame('artIframe')
        self.is_agree_common(status)

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

    def process_is_agree_approval(self, status):
        self.frameElem.from_frame_to_otherFrame('mainFrame')
        self.is_agree_common(status)

    u'''是否同意审批公共方法
		Parameters:
			- status:1代表同意审批,2代表拒绝审批
	'''

    def is_agree_common(self, status):
        statu = self.cnEn.is_float(status)
        if statu == '1':
            self.getElem.find_element_wait_and_click_EC("id", "yes")
        elif statu == '2':
            self.getElem.find_element_wait_and_click_EC("id", "no")

    u'''填写消息中审批申请单的描述
		Parameters:
			- description:描述内容
	'''

    def set_message_apply_description(self, description):
        self.frameElem.from_frame_to_otherFrame("artIframe")
        self.set_apply_description_common(description)

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

    def set_process_apply_description(self, description):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.set_apply_description_common(description)

    u'''填写消息中审批申请单的描述公共方法
		Parameters:
			- description:描述内容
	'''

    def set_apply_description_common(self, description):
        descri = self.cnEn.is_float(description)
        self.getElem.find_element_wait_and_clear("id", "fortApprovalOpinions")
        self.getElem.find_element_wait_and_sendkeys("id",
                                                    "fortApprovalOpinions",
                                                    descri)

    u'''点击关闭按钮'''

    def click_close_button(self):
        self.frameElem.switch_to_content()
        self.getElem.find_element_wait_and_click_EC("classname", "aui_close")

    u'''获取申请历史中最新的申请时间'''

    def get_new_apply_time(self):
        self.frameElem.from_frame_to_otherFrame("topFrame")
        self.cmf.select_menu(u"流程控制", u"申请历史")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        selem = self.getElem.find_element_with_wait_EC(
            "xpath",
            "/html/body/form/div/div[6]/div[2]/div/table/tbody/tr[1]/td[3]")
        applytime = selem.get_attribute('textContent')
        return applytime

    u'''获取申请历史中最新的流程号'''

    def get_new_process_number(self):
        self.frameElem.from_frame_to_otherFrame("topFrame")
        time.sleep(2)
        self.cmf.select_menu(u"流程控制", u"申请历史")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        selem = self.getElem.find_element_with_wait_EC(
            "xpath",
            "/html/body/form/div/div[6]/div[2]/div/table/tbody/tr[1]/td[2]")
        number = selem.get_attribute('textContent')
        time.sleep(3)
        return number

    u'''返回退出公共方法'''

    def back_quit_common(self):
        self.cmf.back()
        self.driver.implicitly_wait(5)
        self.loginElem.quit()

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

    def click_message_button(self):
        self.driver.switch_to_default_content()
        time.sleep(2)
        self.frame_public_method(u"提示", u"提示×保存成功!确定")

    u'''弹窗的公用方法
		Parameters:
			- pagetext:页面弹框的title文本
			- tabletext:表格文本
	'''

    def frame_public_method(self, pagetext, tabletext):

        self.frameElem.switch_to_content()
        #获取title集合
        divselems = self.driver.find_elements_by_class_name("aui_title")
        #获取table集合
        tableselems = self.driver.find_elements_by_class_name("aui_dialog")
        #是否点击确定按钮标识,如果为True说明已经点击确定按钮
        step = False

        #循环table集合
        for table in tableselems:
            #获取table文本
            test = table.get_attribute('textContent')
            #循环title集合
            for divselem in divselems:
                #获取title文本
                messagetext = divselem.get_attribute('textContent')
                if messagetext == pagetext and test == tabletext:
                    table.find_element_by_class_name(
                        "aui_state_highlight").click()
                    step = True
                    break
            if step is True:
                break

    u'''勾选审批人
		Parameters:
			- approvers:审批者集合
	'''

    def check_the_approver(self, approvers):
        self.frameElem.from_frame_to_otherFrame("artIframe")
        #获取span集合
        spanselems = self.driver.find_elements_by_tag_name("span")
        apvers = approvers.split()
        #循环审批者集合进行勾选操作
        for approver in apvers:
            for span in spanselems:
                #获取span的内容
                test = span.get_attribute('textContent')
                if test == approver:
                    span.find_element_by_tag_name("input").click()
                    break

    u'''紧急运维中全选审批人'''

    def check_all_approver(self):
        self.frameElem.from_frame_to_otherFrame("artIframe")
        #获取input集合
        inputselems = self.driver.find_elements_by_class_name("choseAll")
        for input in inputselems:
            input.click()

    u'''点击刷新图标
		parameters :
			rename : 资源名称
	'''

    def click_refresh_icon(self, rename):
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        rname = self.cnEn.is_float(rename)
        row = self.find_name_by_row(rname, "fortResourceName")
        xpath = "/html/body/div[1]/div[7]/div[2]/div/table/tbody/tr[" + str(
            row * 2) + "]/td/div/table/tbody/tr/td[3]/a/img"
        isExsit = self.getElem.is_element_exsit("xpath", xpath)

        if isExsit == True:
            self.getElem.find_element_wait_and_click_EC("xpath", xpath)

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

    def check_access_ico_len(self, rename):
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        time.sleep(5)
        row = self.select_resoure_sso(rename)
        self.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]"
        selem = self.getElem.find_element_with_wait_EC("xpath", ico_xpath)
        selems = selem.find_elements_by_tag_name("a")
        lengh = len(selems)
        if lengh > 2:
            self.log.log_detail(u"访问审批已同意申请,可进行单点登录操作", True)
        else:
            self.log.log_detail(u"访问审批已拒绝申请,不可进行单点登录操作", True)

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

    def send_access_approval_applicant(self, data):
        # 时间控件的fram的xpath
        fxpath = "//iframe[@hidefocus='true']"
        # 日期控件table的xpath路径
        txpath = "/html/body/div/div[3]/table"
        self.select_resoure_account(data[1], data[2])
        time.sleep(2)
        self.click_access_approval_icon(data[1], data[3])
        self.frameElem.from_frame_to_otherFrame("artIframe")
        time.sleep(2)
        self.cmf.select_time("fortStartTime", fxpath, data[4], data[5], txpath)
        self.frameElem.from_frame_to_otherFrame("artIframe")
        # 转成datetime对象
        date = datetime(*xldate_as_tuple(data[9], 0))
        endtime = date.strftime('%Y-%m-%d %H:%M:%S')
        status = self.cnEn.is_float(data[7])
        self.cmf.select_time("fortEndTime", fxpath, status, data[8], txpath,
                             endtime)
        self.set_operation_description(data[10])
        self.log.log_detail(data[0], True)
        self.click_sure_button()
        self.click_message_button()

    u'''审批人通过消息进行审批
		Parameters:
			- acpData:审批人进行审批的数据
			- applytime:申请时间
	'''

    def approval_by_message_approver(self, acpData, applytime):
        for dataRow in range(len(acpData)):
            data = acpData[dataRow]
            # 如果不是第1行,读取数据
            if dataRow != 0:
                self.user_login(data[0])
                self.click_message_prompt()
                self.click_all_message()
                self.click_approval_by_message(applytime)
                if data[1] != 'no':
                    self.message_is_agree_approval(data[1])
                if data[2] != 'no':
                    self.set_message_apply_description(data[2])
                if data[1] == 'no' and data[2] == 'no':
                    self.click_close_button()
                    self.loginElem.quit()
                    continue
                self.click_sure_button()
                self.loginElem.quit()

    u'''审批人通过流程控制进行审批
		Parameters:
			- acpData:审批人进行审批的数据
			- number:流程号
	'''

    def approval_by_approver(self, acpData, number):
        for dataRow in range(len(acpData)):
            data = acpData[dataRow]
            # 如果不是第1行,读取数据
            if dataRow != 0:
                self.user_login(data[1])
                time.sleep(2)
                self.frameElem.from_frame_to_otherFrame("topFrame")
                self.cmf.select_menu(u"流程控制", u"流程任务")
                time.sleep(2)
                if dataRow == 2 or dataRow == 3:
                    # 获取第一行数据的第1个字符
                    firststr = str(acpData[1][2])
                    if firststr == '2.0':
                        self.loginElem.quit()
                        self.log.log_detail(data[0], True)
                        continue
                self.click_approval_by_number(number)
                if data[2] != 'no':
                    self.process_is_agree_approval(data[2])
                if data[3] != 'no':
                    self.set_process_apply_description(data[3])
                if data[2] == 'no' and data[3] == 'no':
                    self.back_quit_common()
                    self.log.log_detail(data[0], True)
                    continue
                self.log.log_detail(data[0], True)
                self.click_submit()
                self.cmf.click_login_msg_button()
                self.back_quit_common()

    u'''申请人发送紧急运维申请
		Parameters:
			- data:excel中的一行数据
	'''

    def send_urgent_operation_applicant(self, data):

        self.select_resoure_account(data[1], data[2])
        self.click_access_approval_icon(data[1], data[3])
        #全选审批人
        self.check_all_approver()
        #可单独选择一级二级审批人
        # self.check_the_approver(data[4])
        self.set_operation_description(data[5])
        self.log.log_detail(data[0], True)
        self.click_sure_button()
        self.click_message_button()
Esempio n. 12
0
class testOptReport():
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.cmf = commonFun(driver)
        self.getElem = getElement(driver)
        self.cnEnde = cnEncode()
        self.confReport = ConfReportPage(self.driver)
        self.optReport = OptReportPage(self.driver)
        self.tableElem = tableElement(self.driver)
        self.selectElem = selectElement(driver)
        self.dataFile = dataFileName()
        self.frameElem = frameElement(self.driver)
        self.loginFun = loginPage(self.driver)
        self.commonSuite = CommonSuiteData(self.driver)
        self.authElem = AuthorizationPage(self.driver)

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

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

        return login_msg

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

    def get_table_data(self, sheetname):
        dataFile = dataFileName()
        filePath = dataFile.get_opt_report_test_url()
        reportData = dataFile.get_data(filePath, sheetname)
        return reportData

    u'''添加行为审计报表'''

    def add_opt_report_001(self):
        #日志开始记录
        self.log.log_start("AddOptReport_001")
        #获取行为报表添加的数据
        ad_data = self.get_table_data("add_opt_report")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(ad_data)):
            data = ad_data[dataRow]
            self.optReport.switch_to_opt_report()
            status = self.optReport.check_report_is_exist(data[2])
            if status == False:
                break
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    if status == True:
                        self.confReport.set_module_name(data[2])
                        self.confReport.set_user_account(data[3])
                        self.optReport.set_res_account(data[4])
                        self.confReport.select_group(data[5])
                        self.optReport.select_res_group(data[6])
                        self.optReport.sel_sigle_type(data[7])
                        self.optReport.sel_sigle_type(data[8])
                        self.optReport.sel_all_field()
                        self.confReport.click_add_module()
                    #判断测试项是否通过
                    self.driver.switch_to_default_content()
                    self.cmf.test_win_check_point("xpath", self.login_msg(),
                                                  data, flag)
                    #清空标识状态
                    flag = False
            except Exception as e:
                print("Add opt report fail: ") + str(e)
        self.log.log_end("AddOptReport_001")

    u'''添加行为审计报表校验'''

    def opt_report_check_002(self):
        #日志开始记录
        self.log.log_start("OptReportCheck_002")
        #获取校验行为报表的数据
        ad_data = self.get_table_data("opt_report_check")
        self.optReport.switch_to_opt_report()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(ad_data)):
            data = ad_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.confReport.set_module_name(data[2])
                    self.optReport.sel_all_field()
                    if dataRow == 2:
                        self.optReport.unsel_all_field()
                    self.confReport.click_add_module()
                    #判断测试项是否通过
                    self.driver.switch_to_default_content()
                    self.cmf.test_win_check_point("xpath", self.login_msg(),
                                                  data, flag)
                    #清空标识状态
                    flag = False
            except Exception as e:
                print("Opt Report Check fail: ") + str(e)
        self.log.log_end("OptReportCheck_002")

    u'''添加和修改行为审计计划模板'''

    def add_plan_report_003(self):
        #日志开始记录
        self.log.log_start("AddPlanReport_003")
        #获取添加计划模板的数据
        ad_data = self.get_table_data("add_plan_export")
        self.optReport.switch_to_opt_report()
        self.optReport.plan_report_btn()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(ad_data)):
            data = ad_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.confReport.select_report(data[2])
                    self.optReport.sel_cycle_type(data[3])
                    if data[3] != "天":
                        self.optReport.sel_cycle_date(data[4])
                    self.optReport.set_time(data[5])
                    if dataRow == 1:
                        self.optReport.set_switch_to_on()
                        self.optReport.sel_email_user_btn()
                        self.authElem.set_select_user_search_button()
                        self.authElem.set_user_check_all_button()
                        self.authElem.set_ok_button()
                    if dataRow == 2:
                        self.optReport.set_switch_to_off()
                    self.optReport.click_save()
                    #判断测试项是否通过
                    self.driver.switch_to_default_content()
                    self.cmf.test_win_check_point("xpath", self.login_msg(),
                                                  data, flag)
                    #清空标识状态
                    flag = False
            except Exception as e:
                print("Add plan report fail: ") + str(e)
        self.optReport.click_back()
        self.log.log_end("AddPlanReport_003")

    u'''删除行为审计报表'''

    def opt_report_del_004(self):
        #日志开始记录
        self.log.log_start("OptReportDel_004")
        #获取删除行为报表的数据
        ad_data = self.get_table_data("del_opt_report")
        self.optReport.switch_to_opt_report()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(ad_data)):
            data = ad_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    #self.optReport.switch_to_opt_report()
                    self.confReport.select_report(data[2])
                    self.confReport.click_del_module()
                    #判断测试项是否通过
                    self.driver.switch_to_default_content()
                    self.cmf.test_win_check_point("xpath", self.login_msg(),
                                                  data, flag)
                    #清空标识状态
                    flag = False
            except Exception as e:
                print("Opt Report del fail: ") + str(e)
        self.log.log_end("OptReportDel_004")
Esempio n. 13
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))
Esempio n. 14
0
class testOptReport():
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.confReport = ConfReportPage(self.driver)
		self.optReport = OptReportPage(self.driver)
		self.tableElem = tableElement(self.driver)
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
		self.loginFun = loginPage(self.driver)
		self.commonSuite = CommonSuiteData(self.driver)
		self.authElem = AuthorizationPage(self.driver)
	
	u'''提示内容框元素路径'''
	def login_msg(self):
		login_msg = "html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/ \
		tbody/tr[2]/td[2]/div"
		return login_msg

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

	u'''添加行为审计报表'''
	def add_opt_report_001(self):
		#日志开始记录
		self.log.log_start("AddOptReport_001")
		#获取行为报表添加的数据
		ad_data = self.get_table_data("add_opt_report")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(ad_data)):
			data = ad_data[dataRow]
			self.optReport.switch_to_opt_report()
			status = self.optReport.check_report_is_exist(data[2])
			if status == False:
				break
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0 :
					if status == True:
						self.confReport.set_module_name(data[2])
						self.confReport.set_user_account(data[3])
						self.optReport.set_res_account(data[4])
						self.confReport.select_group(data[5])
						self.optReport.select_res_group(data[6])
						self.optReport.sel_sigle_type(data[7])
						self.optReport.sel_sigle_type(data[8])
						self.optReport.sel_all_field()
						self.confReport.click_add_module()
					#判断测试项是否通过
					self.driver.switch_to_default_content()
					self.cmf.test_win_check_point("xpath",self.login_msg(),data,flag)
					#清空标识状态
					flag = False
			except Exception as e:
				print ("Add opt report fail: ") + str(e)
		self.log.log_end("AddOptReport_001")

	u'''添加行为审计报表校验'''
	def opt_report_check_002(self):
		#日志开始记录
		self.log.log_start("OptReportCheck_002")
		#获取校验行为报表的数据
		ad_data = self.get_table_data("opt_report_check")
		self.optReport.switch_to_opt_report()
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(ad_data)):
			data = ad_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0 :
					self.confReport.set_module_name(data[2])
					self.optReport.sel_all_field()
					if dataRow == 2:
						self.optReport.unsel_all_field()
					self.confReport.click_add_module()
					#判断测试项是否通过
					self.driver.switch_to_default_content()
					self.cmf.test_win_check_point("xpath",self.login_msg(),data,flag)
					#清空标识状态
					flag = False
			except Exception as e:
				print ("Opt Report Check fail: ") + str(e)
		self.log.log_end("OptReportCheck_002")

	u'''添加和修改行为审计计划模板'''
	def add_plan_report_003(self):
		#日志开始记录
		self.log.log_start("AddPlanReport_003")
		#获取添加计划模板的数据
		ad_data = self.get_table_data("add_plan_export")
		self.optReport.switch_to_opt_report()
		self.optReport.plan_report_btn()
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(ad_data)):
			data = ad_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0 :
					self.confReport.select_report(data[2])
					self.optReport.sel_cycle_type(data[3])
					if data[3] != "天":
						self.optReport.sel_cycle_date(data[4])
					self.optReport.set_time(data[5])
					if dataRow == 1:
						self.optReport.set_switch_to_on()
						self.optReport.sel_email_user_btn()
						self.authElem.set_select_user_search_button()
						self.authElem.set_user_check_all_button()
						self.authElem.set_ok_button()
					if dataRow == 2:
						self.optReport.set_switch_to_off()
					self.optReport.click_save()
					#判断测试项是否通过
					self.driver.switch_to_default_content()
					self.cmf.test_win_check_point("xpath",self.login_msg(),data,flag)
					#清空标识状态
					flag = False
			except Exception as e:
				print ("Add plan report fail: ") + str(e)
		self.optReport.click_back()
		self.log.log_end("AddPlanReport_003")
	

	u'''删除行为审计报表'''
	def opt_report_del_004(self):
		#日志开始记录
		self.log.log_start("OptReportDel_004")
		#获取删除行为报表的数据
		ad_data = self.get_table_data("del_opt_report")
		self.optReport.switch_to_opt_report()
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(ad_data)):
			data = ad_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0 :
					#self.optReport.switch_to_opt_report()
					self.confReport.select_report(data[2])
					self.confReport.click_del_module()
					#判断测试项是否通过
					self.driver.switch_to_default_content()
					self.cmf.test_win_check_point("xpath",self.login_msg(),data,flag)
					#清空标识状态
					flag = False
			except Exception as e:
				print ("Opt Report del fail: ") + str(e)
		self.log.log_end("OptReportDel_004")
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 testAuthorization():
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.cmf = commonFun(driver)
        self.getElem = getElement(driver)
        self.cnEnde = cnEncode()
        self.authElem = AuthorizationPage(self.driver)
        self.tableElem = tableElement(self.driver)
        self.selectElem = selectElement(driver)
        self.dataFile = dataFileName()
        self.frameElem = frameElement(self.driver)

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

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

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

    def get_table_data(self, sheetname):
        dataFile = dataFileName()
        filePath = dataFile.get_authorization_test_data_url()
        authFileData = dataFile.get_data(filePath, sheetname)
        return authFileData

    u'''添加数据通用部分'''

    def common_part(self, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.authElem.add_button()
        self.authElem.set_auth_name(data[2])
        self.authElem.set_dep(data[3], data[9])

    u'''添加用户'''

    def add_user(self, data):
        self.authElem.click_add_user()
        self.authElem.set_select_user_name(data[4])
        self.authElem.set_select_user_search_button()
        self.authElem.set_user_check_all_button()
        self.authElem.set_ok_button()

    u'''添加用户组'''

    def add_user_group(self, data):
        self.authElem.click_add_user_group()
        self.authElem.select_user_group(data[5])
        self.authElem.set_ok_button()

    u'''添加资源'''

    def add_res(self, data):
        self.authElem.click_add_res()
        self.authElem.set_select_res_ip(data[6])
        self.authElem.set_select_res_search_button()
        self.authElem.set_res_check_all_button()
        self.authElem.set_ok_button()

    u'''添加资源组'''

    def add_res_group(self, data):
        self.authElem.click_add_res_group()
        self.authElem.select_res_group(data[7])
        self.authElem.set_ok_button()

    u'''添加资源账号'''

    def add_res_account(self, data):
        self.authElem.click_add_res_account()
        self.authElem.set_select_res_account(data[8])
        self.authElem.set_select_res_search_button()
        self.authElem.set_res_check_all_button()
        self.authElem.set_ok_button()

    u'''校验有弹出框类型用例是否通过
			parameters: 
				data : 检查点
				flag : 通过标识(True or False)
	'''

    def check_with_pop_up(self, data, flag):

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

    u'''判断没有弹出框比较条件不等的用例是否通过
			parameters: 
				var1 : 比较条件1
				var2 : 比较条件2
				data : 测试项
	'''

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

    u'''判断没有弹出框,比较条件相等的用例是否通过'''

    def check_with_condition_equal(self, var1, var2, data):

        if var1 == var2:
            self.cmf.test_win_check_point("", "", data, True)
        else:
            self.cmf.test_win_check_point("", "", data, False)

    u'''重置'''

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

    u'''添加用户和资源类型的授权'''

    def add_user_and_res_auth_001(self):
        #日志开始记录
        self.log.log_start("addAuthorization_001")
        #获取添加授权的数据
        user_data = self.get_table_data("add_authorization")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 1 or dataRow == 2:
                    self.common_part(data)

                    self.add_user(data)
                    #添加资源
                    self.add_res(data)

                    self.authElem.save_button()

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

                    #清空标识状态
                    flag = False
                    self.authElem.back_button()
            except Exception as e:
                print("Authorization 001 add fail: ") + str(e)
        self.log.log_end("addAuthorization_001")

    u'''添加用户和资源组类型的授权'''

    def add_user_and_res_group_auth_002(self):
        #日志开始记录
        self.log.log_start("addAuthorization_002")
        #获取添加授权的数据
        user_data = self.get_table_data("add_authorization")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 3:
                    self.common_part(data)

                    self.add_user(data)
                    #添加资源组
                    self.add_res_group(data)

                    self.authElem.save_button()

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

                    #清空标识状态
                    flag = False
                    self.authElem.back_button()
            except Exception as e:
                print("Authorization 002 add fail: ") + str(e)
        self.log.log_end("addAuthorization_002")

    u'''添加用户和资源账号类型的授权'''

    def add_user_and_res_account_auth_003(self):
        #日志开始记录
        self.log.log_start("addAuthorization_003")
        #获取添加授权的数据
        user_data = self.get_table_data("add_authorization")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 4:
                    self.common_part(data)

                    self.add_user(data)
                    #添加资源账号
                    self.add_res_account(data)

                    self.authElem.save_button()

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

                    #清空标识状态
                    flag = False
                    self.authElem.back_button()
            except Exception as e:
                print("Authorization 003 add fail: ") + str(e)
        self.log.log_end("addAuthorization_003")

    u'''添加用户组和资源类型的授权'''

    def add_user_group_and_res_auth_004(self):
        #日志开始记录
        self.log.log_start("addAuthorization_004")
        #获取添加授权的数据
        user_data = self.get_table_data("add_authorization")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 5:
                    self.common_part(data)

                    self.add_user_group(data)
                    #添加资源
                    self.add_res(data)

                    self.authElem.save_button()

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

                    #清空标识状态
                    flag = False
                    self.authElem.back_button()
            except Exception as e:
                print("Authorization 004 add fail: ") + str(e)
        self.log.log_end("addAuthorization_004")

    u'''添加用户组和资源组类型的授权'''

    def add_user_group_and_res_group_auth_005(self):
        #日志开始记录
        self.log.log_start("addAuthorization_005")
        #获取添加授权的数据
        user_data = self.get_table_data("add_authorization")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果是第5行标题,则读取数据
                if dataRow == 6:
                    self.common_part(data)

                    self.add_user_group(data)
                    #添加资源组
                    self.add_res_group(data)

                    self.authElem.save_button()

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

                    #清空标识状态
                    flag = False
                    self.authElem.back_button()
            except Exception as e:
                print("Authorization 005 add fail: ") + str(e)
        self.log.log_end("addAuthorization_005")

    u'''添加用户组和资源账号类型的授权'''

    def add_user_group_and_res_account_auth_006(self):
        #日志开始记录
        self.log.log_start("addAuthorization_006")
        #获取添加授权的数据
        user_data = self.get_table_data("add_authorization")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow == 7:
                    self.common_part(data)

                    self.add_user_group(data)
                    #添加资源账号
                    self.add_res_account(data)

                    self.authElem.save_button()

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

                    #清空标识状态
                    flag = False

                    self.authElem.back_button()
            except Exception as e:
                print("Authorization 006 add fail: ") + str(e)
        self.log.log_end("addAuthorization_006")

    u'''修改授权名称'''

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

                    self.authElem.operate_edit(data[2])
                    self.authElem.set_auth_name(data[3])
                    self.authElem.save_button()
                    self.cmf.click_login_msg_button()

                    auth_name_new = self.authElem.get_auth_name_text()

                    #判断测试项是否通过
                    self.check_without_pop_up(auth_name_new, data[2], data)

                    #清空标识状态
                    flag = False
                    self.authElem.back_button()

            except Exception as e:
                print("Edit uuthorization fail: ") + str(e)
        self.log.log_end("EditAuthorization_007")

    u'''授权校验'''

    def auth_checkout_008(self):
        #日志开始记录
        self.log.log_start("Authorizationcheckout_008")
        #获取授权校验的数据
        user_data = self.get_table_data("authorization_check")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.authElem.add_button()

        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:

                    self.authElem.set_auth_name(data[2])
                    #选择部门
                    if dataRow >= 5:
                        self.authElem.set_dep(data[3])

                    #第6行,添加运维用户
                    if dataRow == 6:
                        self.add_user(data)
                    if dataRow == 7:
                        self.add_user(data)
                        self.add_res(data)
                    self.authElem.save_button()

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

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

    u'''授权查询'''

    def auth_query_009(self):
        #日志开始记录
        self.log.log_start("Authorizationquery_009")
        #获取授权查询的数据
        user_data = self.get_table_data("authorazation_search")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        for dataRow in range(len(user_data)):
            data = user_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.authElem.set_query_conditon(data[2], data[3])

                    self.authElem.click_search_button()
                    self.log.log_detail(data[0], True)

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

    u'''授权删除'''

    def auth_del_010(self):
        #日志开始记录
        self.log.log_start("Deloneauthorization_010")
        #获取删除授权的数据
        auth_data = self.get_table_data("del_authorization")
        #无检查点的测试项标识,如果为True说明通过
        flag = False

        for dataRow in range(len(auth_data)):
            data = auth_data[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    #如果是第一行,删除单条授权
                    self.authElem.click_auth_checkbox(data[2])
                    #如果是第二行删除全部授权
                    self.authElem.del_button()
                    self.cmf.click_login_msg_button()
                    #判断测试项是否通过
                    self.check_with_pop_up(data, flag)

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

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

    def Opt_access_approvel_011(self):
        #日志开始记录
        self.log.log_start("OperationAccessApprovel_011")

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

        #获取访问审批的数据
        auth_data = self.get_table_data("access_approvel")
        for dataRow in range(len(auth_data)):
            data = auth_data[dataRow]
            try:
                #如果不是第1行,读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    #点击访问审批
                    self.authElem.operate_access_approval(data[2])
                    #添加访问审批
                    if dataRow == 1 or dataRow == 2:
                        #设置开关状态
                        self.authElem.set_switch_on()
                        self.authElem.click_add_approval_level()
                        self.authElem.click_add_approval(data[3])
                        #添加审批人
                        self.authElem.set_select_user_name(data[4])
                        self.authElem.set_select_user_search_button()
                        self.authElem.set_user_check_all_button()
                        self.authElem.set_ok_button()
                        #设置审批级别中的通过审批人个数
                        self.authElem.set_approver_num(data[3], data[5])
                    #删除一级审批
                    if dataRow == 3:
                        self.authElem.click_del_approvel(data[3])
                    #重置审批
                    if dataRow == 4:
                        self.authElem.click_approvel_reset_button()
                    #点击保存
                    self.authElem.approval_save_button()
                    self.cmf.click_login_msg_button()
                    #点击返回
                    self.authElem.approval_back_button()
                    #判断测试项是否通过
                    text = self.authElem.get_access_approvel_value(data[2])
                    self.check_with_condition_equal(text, data[6], data)

                    #清空标识状态
                    flag = False

            except Exception as e:
                print("Operation access approvel fail: ") + str(e)

        self.log.log_end("OperationAccessApprovel_011")

    u'''添加双人审批'''

    def add_double_approvel_012(self):
        #日志开始记录
        self.log.log_start("AddDoubleApprovel_012")

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

        #获取访问审批的数据
        auth_data = self.get_table_data("double_approvel")

        for dataRow in range(len(auth_data)):
            data = auth_data[dataRow]
            try:

                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.authElem.operate_double_approval(data[2])
                    #添加双人审批
                    if dataRow == 1 or dataRow == 2:
                        self.authElem.click_start_association()
                        self.authElem.select_status(data[3])
                        self.authElem.double_approvel_account_or_name(data[4])
                        self.authElem.double_approvel_query()
                        #勾选审批人和被审批人
                        self.authElem.click_all_approver()
                        self.authElem.click_all_candidate()
                        self.authElem.click_create_relate()

                    #取消关联
                    if dataRow == 3:
                        self.authElem.click_quit_relate()
                    self.cmf.click_login_msg_button()
                    self.authElem.click_child_page_back_button()
                    text = self.authElem.get_double_approvel_value(data[2])
                    #判断测试项是否通过
                    self.check_with_condition_equal(text, data[6], data)

                    #清空标识状态
                    flag = False

            except Exception as e:
                print("Add double approvel fail: ") + str(e)

        self.log.log_end("AddDoubleApprovel_012")
Esempio n. 17
0
class testAuthorization():
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.authElem = AuthorizationPage(self.driver)
		self.tableElem = tableElement(self.driver)
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
	
	u'''提示框元素路径'''
	def auth_msg(self):
		auth_msg = "html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
		return auth_msg

	u'''获取测试数据
		Parameters:
			- sheetname:sheet名称
			return:表格数据
	'''
	def get_table_data(self,sheetname):
		dataFile = dataFileName()
		filePath = dataFile.get_authorization_test_data_url()
		authFileData = dataFile.get_data(filePath,sheetname)
		return authFileData
	
	u'''添加数据通用部分'''	
	def common_part(self,data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		self.authElem.add_button()
		self.authElem.set_auth_name(data[2])
		self.authElem.set_dep(data[3],data[9])
	
	u'''添加用户'''
	def add_user(self,data):
		self.authElem.click_add_user()
		self.authElem.set_select_user_name(data[4])
		self.authElem.set_select_user_search_button()
		self.authElem.set_user_check_all_button()
		self.authElem.set_ok_button()

	u'''添加用户组'''
	def add_user_group(self,data):
		self.authElem.click_add_user_group()
		self.authElem.select_user_group(data[5])
		self.authElem.set_ok_button()		
	
	u'''添加资源'''
	def add_res(self,data):
		self.authElem.click_add_res()
		self.authElem.set_select_res_ip(data[6])
		self.authElem.set_select_res_search_button()
		self.authElem.set_res_check_all_button()
		self.authElem.set_ok_button()
		
	
	u'''添加资源组'''
	def add_res_group(self,data):
		self.authElem.click_add_res_group()
		self.authElem.select_res_group(data[7])
		self.authElem.set_ok_button()
		
	
	u'''添加资源账号'''
	def add_res_account(self,data):
		self.authElem.click_add_res_account()
		self.authElem.set_select_res_account(data[8])
		self.authElem.set_select_res_search_button()
		self.authElem.set_res_check_all_button()
		self.authElem.set_ok_button()
		
	
	u'''校验有弹出框类型用例是否通过
			parameters: 
				data : 检查点
				flag : 通过标识(True or False)
	'''
	def check_with_pop_up(self,data,flag):
		
		#点击保存按钮弹出框
		auth_msg = self.auth_msg()	
		self.frameElem.switch_to_content()
		self.cmf.test_win_check_point("xpath",auth_msg,data,flag)

	u'''判断没有弹出框比较条件不等的用例是否通过
			parameters: 
				var1 : 比较条件1
				var2 : 比较条件2
				data : 测试项
	'''
	def check_without_pop_up(self,var1,var2,data):
		#点击保存按钮弹出框
		auth_msg = self.auth_msg()
		if var1 != var2:
			self.cmf.test_win_check_point("","",data,True)
		else:
			self.cmf.test_win_check_point("","",data,False)
	
	u'''判断没有弹出框,比较条件相等的用例是否通过'''
	def check_with_condition_equal(self,var1,var2,data):

		if var1 == var2:
			self.cmf.test_win_check_point("","",data,True)
		else:
			self.cmf.test_win_check_point("","",data,False)
	

	u'''重置'''	
	def reset(self):
		self.authElem.click_reset_button()
		self.authElem.click_search_button()
	
	u'''添加用户和资源类型的授权'''
	def add_user_and_res_auth_001(self):		
		#日志开始记录
		self.log.log_start("addAuthorization_001")
		#获取添加授权的数据
		user_data = self.get_table_data("add_authorization")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow == 1 or dataRow == 2:
					self.common_part(data)
					
					self.add_user(data)
					#添加资源
					self.add_res(data)
					
					self.authElem.save_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)
					
					#清空标识状态
					flag = False
					self.authElem.back_button()
#					self.switch_to_auth_module()
#					self.authElem.back_by_key()
#					self.cmf.back()
					if self.cmf.is_namevalue_exsit(data[2],"fortAuthorizationName"):
						print ("add Authorization success")
			except Exception as e:
				print ("Authorization 001 add fail: ") + str(e)
		self.log.log_end("addAuthorization_001")
	
	u'''添加用户和资源组类型的授权'''
	def add_user_and_res_group_auth_002(self):		
		#日志开始记录
		self.log.log_start("addAuthorization_002")
		#获取添加授权的数据
		user_data = self.get_table_data("add_authorization")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow == 3:
					self.common_part(data)
					
					self.add_user(data)
					#添加资源组
					self.add_res_group(data)
					
					self.authElem.save_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)
					
					#清空标识状态
					flag = False
#					self.authElem.back_by_key()
#					self.switch_to_auth_module()
					self.authElem.back_button()
#					self.cmf.back()
					if self.cmf.is_namevalue_exsit(data[2],"fortAuthorizationName"):
						print ("add Authorization success")
			except Exception as e:
				print ("Authorization 002 add fail: ") + str(e)
		self.log.log_end("addAuthorization_002")
	
	u'''添加用户和资源账号类型的授权'''
	def add_user_and_res_account_auth_003(self):	
		#日志开始记录
		self.log.log_start("addAuthorization_003")
		#获取添加授权的数据
		user_data = self.get_table_data("add_authorization")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow == 4:
					self.common_part(data)
					
					self.add_user(data)
					#添加资源账号
					self.add_res_account(data)
					
					self.authElem.save_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)
					
					#清空标识状态
					flag = False
					
#					self.cmf.back()
#					self.switch_to_auth_module()
					self.authElem.back_button()
					if self.cmf.is_namevalue_exsit(data[2],"fortAuthorizationName"):
						print ("add Authorization success")
			except Exception as e:
				print ("Authorization 003 add fail: ") + str(e)
		self.log.log_end("addAuthorization_003")
	
	u'''添加用户组和资源类型的授权'''
	def add_user_group_and_res_auth_004(self):		
		#日志开始记录
		self.log.log_start("addAuthorization_004")
		#获取添加授权的数据
		user_data = self.get_table_data("add_authorization")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow == 5:
					self.common_part(data)
					
					self.add_user_group(data)
					#添加资源
					self.add_res(data)
					
					self.authElem.save_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)
					
					#清空标识状态
					flag = False
					
#					self.cmf.back()
#					self.switch_to_auth_module()
					self.authElem.back_button()
					if self.cmf.is_namevalue_exsit(data[2],"fortAuthorizationName"):
						print ("add Authorization success")
			except Exception as e:
				print ("Authorization 004 add fail: ") + str(e)
		self.log.log_end("addAuthorization_004")
	
	u'''添加用户组和资源组类型的授权'''
	def add_user_group_and_res_group_auth_005(self):		
		#日志开始记录
		self.log.log_start("addAuthorization_005")
		#获取添加授权的数据
		user_data = self.get_table_data("add_authorization")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果是第5行标题,则读取数据
				if dataRow == 6:
					self.common_part(data)
					
					self.add_user_group(data)
					#添加资源组
					self.add_res_group(data)
					
					self.authElem.save_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)
					
					#清空标识状态
					flag = False
					
#					self.cmf.back()
#					self.switch_to_auth_module()
					self.authElem.back_button()
					if self.cmf.is_namevalue_exsit(data[2],"fortAuthorizationName"):
						print ("add Authorization success")
			except Exception as e:
				print ("Authorization 005 add fail: ") + str(e)
		self.log.log_end("addAuthorization_005")
	
	
	u'''添加用户组和资源账号类型的授权'''
	def add_user_group_and_res_account_auth_006(self):		
		#日志开始记录
		self.log.log_start("addAuthorization_006")
		#获取添加授权的数据
		user_data = self.get_table_data("add_authorization")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow == 7:
					self.common_part(data)
					
					self.add_user_group(data)
					#添加资源账号
					self.add_res_account(data)
					
					self.authElem.save_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)
					
					
					#清空标识状态
					flag = False
					
#					self.cmf.back()
#					self.switch_to_auth_module()
					self.authElem.back_button()
					if self.cmf.is_namevalue_exsit(data[2],"fortAuthorizationName"):
						print ("add Authorization success")
			except Exception as e:
				print ("Authorization 006 add fail: ") + str(e)
		self.log.log_end("addAuthorization_006")
	
	u'''修改授权名称'''
	def edit_auth_name_007(self):		
		#日志开始记录
		self.log.log_start("EditAuthorization_007")
		#获取修改授权数据
		user_data = self.get_table_data("mod_authorization")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					
					self.authElem.operate_edit(data[2])
					self.authElem.set_auth_name(data[3])
					self.authElem.save_button()
					self.cmf.click_login_msg_button()
					
					auth_name_new = self.authElem.get_auth_name_text()
					
					#判断测试项是否通过
					self.check_without_pop_up(auth_name_new,data[2],data)
					
					#清空标识状态
					flag = False
					self.authElem.back_button()
					if self.cmf.is_namevalue_exsit(data[3],"fortAuthorizationName"):
						print ("Edit authorization success")
				
			except Exception as e:
				print ("Edit uuthorization fail: ") + str(e)
		self.log.log_end("EditAuthorization_007")
	
	u'''授权校验'''
	def auth_checkout_008(self):	
		#日志开始记录
		self.log.log_start("Authorizationcheckout_008")
		#获取授权校验的数据
		user_data = self.get_table_data("authorization_check")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		self.authElem.add_button()
		
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if  dataRow != 0:

					self.authElem.set_auth_name(data[2])
					#选择部门
					if dataRow >= 5:
						self.authElem.set_dep(data[3])
					
					#第6行,添加运维用户
					if dataRow == 6:
						self.add_user(data)
					if dataRow == 7:
						self.add_user(data)
						self.add_res(data)
					self.authElem.save_button()
					
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)
					
					#清空标识状态
					flag = False
			except Exception as e:
				print ("Authorization checkout fail: ") + str(e)
		self.authElem.back_button()
		self.log.log_end("Authorizationcheckout_008")
	
	u'''授权查询'''
	def auth_query_009(self):		
		#日志开始记录
		self.log.log_start("Authorizationquery_009")
		#获取授权查询的数据
		user_data = self.get_table_data("authorazation_search")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		for dataRow in range(len(user_data)):
			data = user_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if  dataRow != 0:
					self.authElem.set_query_conditon(data[2],data[3])

					self.authElem.click_search_button()
					self.log.log_detail(data[0], True)
#					search_row = self.authElem.get_rows()
#					row = self.authElem.set_query_name(data[2],data[4])
#					
#					#判断测试项是否通过
#					self.check_with_condition_equal(search_row,row,data)
					
					#清空标识状态
					flag = False
					self.reset()
			except Exception as e:
				print ("Authorization checkout fail: ") + str(e)
		self.log.log_end("Authorizationcheckout_009")
	
	u'''授权删除'''
	def auth_del_010(self):	
		#日志开始记录
		self.log.log_start("Deloneauthorization_010")
		#获取删除授权的数据
		auth_data = self.get_table_data("del_authorization")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		
		for dataRow in range(len(auth_data)):
			data = auth_data[dataRow]
			try:
				#如果不是第1行,读取数据
				if  dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					#如果是第一行,删除单条授权
					#if dataRow == 1:
					self.authElem.click_auth_checkbox(data[2])
					#如果是第二行删除全部授权
#					if dataRow == 2:
#						self.authElem.check_all()
					self.authElem.del_button()
					self.cmf.click_login_msg_button()
					#判断测试项是否通过
					self.check_with_pop_up(data,flag)
					
					#清空标识状态
					flag = False
			except Exception as e:
				print ("Del one authorization fail: ") + str(e)
		self.log.log_end("Deloneauthorization_010")

	u'''添加访问审批'''
	def Opt_access_approvel_011(self):		
		#日志开始记录
		self.log.log_start("OperationAccessApprovel_011")
		
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		
		#获取访问审批的数据
		auth_data = self.get_table_data("access_approvel")
		for dataRow in range(len(auth_data)):
			data = auth_data[dataRow]
			try:
				#如果不是第1行,读取数据
				if  dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					#点击访问审批
					self.authElem.operate_access_approval(data[2])
					#添加访问审批
					if dataRow == 1 or dataRow == 2:
						#设置开关状态
						self.authElem.set_switch_on()
						self.authElem.click_add_approval_level()
						self.authElem.click_add_approval(data[3])
						#添加审批人
						self.authElem.set_select_user_name(data[4])
						self.authElem.set_select_user_search_button()
						self.authElem.set_user_check_all_button()
						self.authElem.set_ok_button()
						#设置审批级别中的通过审批人个数
						self.authElem.set_approver_num(data[3],data[5])
					#删除一级审批
					if dataRow == 3:
						self.authElem.click_del_approvel(data[3])
					#重置审批
					if dataRow == 4:
						self.authElem.click_approvel_reset_button()
					#点击保存
					self.authElem.approval_save_button()
					self.cmf.click_login_msg_button()
					#点击返回
					self.authElem.approval_back_button()
					#判断测试项是否通过
					text = self.authElem.get_access_approvel_value(data[2])
					self.check_with_condition_equal(text,data[6],data)

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

	u'''添加双人审批'''
	def add_double_approvel_012(self):	
		#日志开始记录
		self.log.log_start("AddDoubleApprovel_012")
		
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		
		#获取访问审批的数据
		auth_data = self.get_table_data("double_approvel")
		
		for dataRow in range(len(auth_data)):
			data = auth_data[dataRow]
			try:
				
				if  dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.authElem.operate_double_approval(data[2])
					#添加双人审批
					if dataRow == 1 or dataRow == 2:
						self.authElem.click_start_association()
						self.authElem.select_status(data[3])
						self.authElem.double_approvel_account_or_name(data[4])
						self.authElem.double_approvel_query()
						#勾选审批人和被审批人
						self.authElem.click_all_approver()
						self.authElem.click_all_candidate()
						self.authElem.click_create_relate()

					#取消关联
					if dataRow == 3:
						self.authElem.click_quit_relate()
					self.cmf.click_login_msg_button()
					self.authElem.click_child_page_back_button()
					text = self.authElem.get_double_approvel_value(data[2])
					#判断测试项是否通过
					self.check_with_condition_equal(text,data[6],data)
					
					#清空标识状态
					flag = False
		
			except Exception as e:
				print ("Add double approvel fail: ") + str(e)
		
		self.log.log_end("AddDoubleApprovel_012")

#if __name__ == "__main__":
#	browser = setDriver().set_local_driver()
#	commonSuite = CommonSuiteData(browser)
	
	#commonSuite.authori_module_prefix_condition()
	
#	commonSuite.isomper_login()
#	commonSuite.add_sys_role()
#	commonSuite.add_dep_role()
#	commonSuite.add_user_with_role()
#	commonSuite.add_authorization_user()
#	commonSuite.user_quit()

#	commonSuite.login_and_switch_to_dep()
#	cmf = commonFun(browser)
#	commonSuite.switch_to_moudle(u'运维管理',u'授权')
#	authElem = AuthorizationPage(browser)
#	authTest = testAuthorization(browser)
#
#
#
#	authTest.add_user_and_res_auth_001()
#	authTest.add_user_and_res_group_auth_002()
#	authTest.add_user_and_res_account_auth_003()
#	authTest.add_user_group_and_res_auth_004()
#	authTest.add_user_group_and_res_group_auth_005()
#	authTest.add_user_group_and_res_account_auth_006()
#	authTest.edit_auth_name_007()
#	authTest.auth_checkout_008()
#	
#	authTest.auth_query_009()
#	
#	authTest.Opt_access_approvel_011()
#	authTest.add_double_approvel_012()
#	authTest.auth_del_010()
Esempio n. 18
0
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")
Esempio n. 19
0
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")
Esempio n. 20
0
class CommonSuiteData():
    def __init__(self, driver):
        self.driver = driver
        self.dataFile = dataFileName()
        self.cmf = commonFun(self.driver)
        self.initDriver = initDriver()
        self.loginElem = loginPage(self.driver)
        self.roleElem = Role(self.driver)
        self.userElem = UserPage(self.driver)
        self.frameElem = frameElement(self.driver)
        self.authElem = AuthMethodPage(self.driver)
        self.dptment = Department(self.driver)
        self.resource = Resource(self.driver)
        self.account = Accountmgr(self.driver)
        self.windowsElem = WindowsResource(self.driver)
        self.databaseElem = DatabaseResource(self.driver)
        self.usergroup = Usergroup(self.driver)
        self.regroup = Regroup(self.driver)
        self.appElem = AppPage(self.driver)
        self.authorizationElem = AuthorizationPage(self.driver)
        self.testAutho = testAuthorization(self.driver)
        self.clientElem = ClientPage(self.driver)
        self.command = CommandRule(self.driver)
        self.ntp = NtpService(self.driver)
        self.mail = MailPage(self.driver)
        self.syslog = Syslog(driver)
        self.ssoElem = SsoPage(self.driver)
        self.alarm = AlarmPage(self.driver)
        self.PwdStr = PwdStrategy(self.driver)
        self.passwdenvelope = EnvelopePage(self.driver)

    u'''切换模块
            parameter:
                levelText1 : 一级模块名称
                levelText2 : 二级模块名称
    '''

    def switch_to_moudle(self, levelText1, levelText2):
        time.sleep(2)
        self.frameElem.from_frame_to_otherFrame("topFrame")

        self.cmf.select_menu(levelText1)
        self.cmf.select_menu(levelText1, levelText2)

#----------------------------------------用户相关------------------------------

    u'''填写用户信息
            parameters:
                data[1] : 用户名称
                data[3] : 用户账号
                data[4] : 用户密码
                data[5] : 确认密码
                data[6] : 开始时间
                data[7] : 访问方式
                data[8] : AD域账号
                roleText : 用户角色
    '''
    def set_user_basic_info(self, data, roleText, status='no'):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        if status != 'no':
            self.userElem.add_role_button()
        else:
            self.userElem.add_button()
        self.userElem.set_user_account(data[3])
        self.userElem.set_user_name(data[1])
        self.userElem.set_user_pwd(data[4])
        self.userElem.set_user_enquire_pwd(data[5])
        self.userElem.set_start_time(data[6])
        if data[12] != "":
            self.userElem.set_user_email(data[12])
        if data[10] != "":
            self.userElem.set_dep(data[10])
        if data[7] != "":
            #设置访问方式
            self.userElem.click_advanced_option()
            self.userElem.set_auth_method_rule(data[7])

            #访问方式不是默认方式
            if int(data[7]) != 2:
                self.userElem.set_ad_name(data[8])
        if data[9] != "":
            self.userElem.set_user_role(roleText)
            self.userElem.click_role_add_button()
        self.userElem.save_button()
        self.cmf.click_login_msg_button()

    u'''删除用户'''

    def del_user(self):
        self.switch_to_moudle(u"运维管理", u"用户")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.userElem.select_all_button()
        self.userElem.del_button()
        self.frameElem.switch_to_content()
        self.cmf.click_login_msg_button()
        self.cmf.click_login_msg_button()

    u'''用户退出'''

    def user_quit(self):
        self.loginElem.quit()

#-----------------------------部门--------------------------------------------

    u'''填写部门名称
            parameters :
                data[0] : 部门名称
                data[1] : 操作类型(添加:0)
                data[2] : 添加的部门名称
    '''
    def set_dep(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.dptment.click_left_department()
        #点击展开按钮
        self.dptment.click_dept_switch()
        self.dptment.click_basic_operation(data[0], int(data[1]))
        self.dptment.popup_sendkey(data[2])
        self.dptment.click_ok_button()
        self.cmf.click_login_msg_button()

    def set_del_dep(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.dptment.click_left_department()
        self.dptment.click_dept_switch()
        self.dptment.click_basic_operation(data[0], int(data[1]))
        self.cmf.click_login_msg_button()
        self.cmf.click_login_msg_button()

#-----------------------------用户组------------------------------------------

    u'''添加用户到用户组'''
    def set_user_to_group(self, data):
        #        self.usergroup.click_left_usergroup()
        #        self.usergroup.click_usergroup_switch()
        self.usergroup.click_usergroup_add_user(data[3], data[4])
        self.regroup.check_depart(data[5])
        self.usergroup.click_usergroup_add_user_query()
        self.regroup.check_all_resource()
        self.regroup.click_resource_okbutton()
        self.cmf.click_login_msg_button()

    u'''填写用户组信息
            parameters:
                data[0] : 操作类型(添加:0)
                data[1] : 部门名称
                data[2] : 编辑的用户组名称
                data[3] : 添加的用户组名称
    '''

    def set_add_user_group(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.usergroup.click_left_usergroup()
        self.usergroup.click_usergroup_switch()
        self.usergroup.usergroup_click_basic_operation(int(data[0]), data[1],
                                                       data[2])
        self.dptment.popup_sendkey(data[3])
        self.dptment.click_ok_button()
        self.cmf.click_login_msg_button()
        if data[4] != "":
            self.set_user_to_group(data)

    u'''删除用户组
            parameters :
                data[0] : 操作类型(删除:4)
                data[1] : 部门名称
                data[2] : 删除的用户组名称
    '''

    def set_del_user_group(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.usergroup.click_left_usergroup()
        self.usergroup.click_usergroup_switch()
        self.usergroup.usergroup_click_basic_operation(int(data[0]), data[1],
                                                       data[2])
        self.cmf.click_login_msg_button()
        self.cmf.click_login_msg_button()

#-----------------------------资源组------------------------------------------

    u'''添加资源到资源组'''
    def set_res_to_group(self, data):
        self.regroup.click_regroup_add_resouce(data[3], data[4])
        self.regroup.check_depart(data[5])
        self.regroup.click_regroup_add_resouce_query()
        self.regroup.check_all_resource()
        self.regroup.click_resource_okbutton()
        time.sleep(1)
        self.cmf.click_login_msg_button()

    u'''填写资源组信息
            parameters:
                data[0] : 操作类型(添加:0)
                data[1] : 部门名称
                data[2] : 编辑的资源组名称
                data[3] : 添加的资源组名称
    '''

    def set_add_res_group(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.regroup.click_left_regroup()
        self.regroup.click_regroup_switch()
        self.regroup.regroup_click_basic_operation(int(data[0]), data[1],
                                                   data[2])
        self.dptment.popup_sendkey(data[3])
        self.dptment.click_ok_button()
        self.cmf.click_login_msg_button()
        if data[4] != "":
            self.set_res_to_group(data)

    u'''删除资源组
            parameters :
                data[0] : 操作类型(删除:4)
                data[1] : 部门名称
                data[2] : 删除的资源组名称
    '''

    def set_del_res_group(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.regroup.click_left_regroup()
        self.regroup.click_regroup_switch()
        self.regroup.regroup_click_basic_operation(int(data[0]), data[1],
                                                   data[2])
        self.cmf.click_login_msg_button()
        self.cmf.click_login_msg_button()

#-----------------------------资源--------------------------------------------

    u'''填写资源基本信息
            parameters : 
                data[0]:资源类型
                data[1]:资源名称
                data[2]:资源IP
                data[3]:部门
    '''
    def set_resource_info(self, data):
        self.switch_to_moudle(u"运维管理", u"资源")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.resource.click_add_edit_button()
        self.resource.select_resource_type(data[0])
        self.resource.set_resource_name(data[1])
        self.resource.set_resource_ip(data[2])
        if data[3] != 'no':
            time.sleep(5)
            self.resource.set_depart(data[3])
        #选择协议
        if data[4] != "":
            self.resource.select_agreement(data[4])
        if data[5] != "":
            self.resource.click_account_sync()
            self.resource.set_admin_account(data[5])
            self.resource.set_admin_pwd(data[6])
            self.resource.set_confirm_pwd(data[7])
        #提权口令
        if data[8] != "":
            self.resource.click_up_super()
            self.resource.set_super_pwd(data[8])
            self.resource.set_super_confirm_pwd(data[9])
        #填写域名
        if data[10] != "":
            self.databaseElem.set_domain_name(data[10])
        #账号分类
        if data[11] != "":
            self.resource.click_account_sync()
            self.windowsElem.select_account_type(data[11])
        #归属域控主机
        if data[12] != "":
            self.windowsElem.select_attach_domian(data[12])
        #主机名
        if data[13] != "":
            self.databaseElem.set_host_name(data[13])

        self.resource.click_save_button()
        self.cmf.click_login_msg_button()
        time.sleep(3)
        #        self.driver.implicitly_wait(3)
        self.cmf.back()

    u'''填写数据库基本信息'''

    def set_database_res_info(self, data):
        self.switch_to_moudle(u"运维管理", u"资源")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.resource.click_add_edit_button()
        self.resource.select_resource_type(data[2])
        self.databaseElem.add_edit_database_resource(data)
        self.cmf.click_login_msg_button()
        time.sleep(3)
        self.cmf.back()

    u'''填写资源账号基本信息
            parameters: 
                data[1]:资源名称
                data[4] : 账号编辑方式
                data[5] : 账号名称
                data[6] : 口令
                data[7] : 确认口令
    '''

    def set_res_account(self, data):
        self.switch_to_moudle(u"运维管理", u"资源")
        self.account.click_account_manage_button(data[0])
        time.sleep(1)
        self.account.click_account_add_edit_button(data[2])
        self.account.select_edit_way(data[1])
        if data[2] != "no":
            self.account.set_account_name(data[2])
        self.account.set_account_pwd(data[3])
        self.account.set_account_confirm_pwd(data[4])
        self.account.set_authorize()
        self.account.click_save_account()
        self.cmf.click_login_msg_button()

#-----------------------------授权----------------------------------------

    u'''填写授权基本信息
            parameters:
                data[1]:授权名称
                data[2]:部门名称
                data[3]:状态
    '''
    def set_authorization(self, data):
        self.switch_to_moudle(u'运维管理', u'授权')
        self.authorizationElem.add_button()
        self.authorizationElem.set_auth_name(data[1])
        self.authorizationElem.set_dep(data[2], data[3])
        self.authorizationElem.click_add_user()
        self.authorizationElem.set_select_user_search_button()
        self.authorizationElem.set_user_check_all_button()
        self.authorizationElem.set_ok_button()
        #添加资源
        self.authorizationElem.click_add_res()
        self.authorizationElem.set_select_res_search_button()
        self.authorizationElem.set_res_check_all_button()
        self.authorizationElem.set_ok_button()
        self.authorizationElem.save_button()
        self.cmf.click_login_msg_button()
        self.cmf.back()
#---------------------------------填写应用发布信息----------------------------

    u'''填写应用发布信息'''
    def set_application_info(self, data):
        self.switch_to_moudle(u"系统配置", u"关联服务")
        self.appElem.app_module_button()
        self.appElem.click_add_button()
        self.appElem.set_name(data[0])
        self.appElem.set_ip(data[1])
        self.appElem.set_app_account(data[3])
        self.appElem.set_pwd(data[4])
        self.appElem.set_repwd(data[5])
        self.appElem.ip_is_succ()
        self.appElem.click_save_button()
        self.cmf.click_login_msg_button()

    u'''删除应用发布'''

    def del_application(self, rowList):
        self.switch_to_moudle(u"系统配置", u"关联服务")
        self.appElem.app_module_button()
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        app_data = self.get_table_data("add_application")
        for dataRow in rowList:
            data = app_data[dataRow]
            if dataRow != 0:
                self.appElem.operate_del(data[0])
                self.cmf.click_login_msg_button()
                self.cmf.click_login_msg_button()

#-------------------------------------客户端-----------------------------------

    u'''填写客户端基本信息'''
    def set_client_info(self, data):
        #self.switch_to_moudle(u"系统配置",u"客户端配置")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.clientElem.add_button()
        self.clientElem.set_client_name(data[2])
        self.clientElem.set_action_stream(data[3])
        self.clientElem.set_database_res_type(data[0], data[1])
        self.clientElem.save_button()

    u'''删除客户端'''

    def set_delete_client_info(self, data):
        #self.switch_to_moudle(u"系统配置",u"客户端配置")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.clientElem.select_query_res_type(data[0], data[1])
        self.clientElem.click_query_button()
        self.clientElem.del_operation(data[2])
        self.cmf.click_login_msg_button()

#------------------------------资源账号授权------------------------------------

    u'''添加用户和资源账号类型的授权'''
    def set_authorization_info(self, data):
        self.switch_to_moudle(u"运维管理", u"授权")
        self.testAutho.common_part(data)
        self.testAutho.add_user(data)
        self.authorizationElem.click_add_res_account()
        self.authorizationElem.set_select_res_ip(data[6])
        self.authorizationElem.set_select_res_account(data[8])
        self.authorizationElem.set_select_res_search_button()
        self.authorizationElem.set_res_check_all_button()
        self.authorizationElem.set_ok_button()
        self.authorizationElem.res_account_status()
        self.authorizationElem.save_button()
        self.cmf.click_login_msg_button()

    u'''删除授权'''

    def del_authorization(self):
        self.switch_to_moudle(u"运维管理", u"授权")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.authorizationElem.check_all()
        self.authorizationElem.del_button()
        self.cmf.click_login_msg_button()
        self.cmf.click_login_msg_button()

#-----------------------------数据----------------------------------------

    u'''获取数据
        Parameters:
            - sheetname:sheet名称
            return:表格数据
    '''
    def get_table_data(self, sheetname):
        filePath = self.dataFile.get_common_suite_test_data_url()
        fileData = self.dataFile.get_data(filePath, sheetname)
        return fileData

    u'''添加应用发布'''

    def add_application(self, rowList):
        app_data = self.get_table_data('add_application')
        for dataRow in rowList:
            data = app_data[dataRow]
            if dataRow != 0:
                self.set_application_info(data)

    u'''初始化用户登录'''

    def isomper_login(self):
        login_data = self.get_table_data('add_user')
        logindata = login_data[4]
        self.loginElem.login(logindata)

    u'''添加用户数据模板'''

    def add_user_data_module(self, rowList):
        self.switch_to_moudle(u"运维管理", u"用户")
        user_data = self.get_table_data("add_user")
        for dataRow in rowList:
            data = user_data[dataRow]
            if dataRow != 0:
                self.set_user_basic_info(data, data[9], data[13])
                self.userElem.click_back_button()

    u'''添加系统管理员和部门管理员的用户'''

    def add_user_with_role(self):
        rowList = [1]
        self.add_user_data_module(rowList)

    u'''登录并切换至角色公用方法
            parameters: 
                login_status :'no'(登录状态:没有登录)
    '''

    def login_and_switch_to_common(self, login_status='no'):
        login_data = self.get_table_data("add_user")
        logindata = login_data[1]
        if login_status == 'no':
            self.loginElem.login(logindata)

        #获取角色
        roleList = logindata[9].split(',')
        return roleList

    u'''使用系统管理员登录系统'''

    def login_sysadmin(self):
        login_data = self.get_table_data('add_user')
        logindata = login_data[1]
        self.loginElem.login(logindata)

    u'''使用安全保密管理员登录系统'''

    def login_secadmin(self):
        login_data = self.get_table_data('add_user')
        logindata = login_data[2]
        self.loginElem.login(logindata)

    u'''使用安全审计员登录系统'''

    def login_sysaudit(self):
        login_data = self.get_table_data('add_user')
        logindata = login_data[3]
        self.loginElem.login(logindata)

    u'''用户登录系统'''

    def login_user(self, row):
        login_data = self.get_table_data('add_user')
        logindata = login_data[int(row)]
        self.loginElem.login(logindata)

    u'''切换至运维操作员'''

    def switch_to_operation(self):
        self.cmf.select_role_by_text(u"运维操作员")

    #使用新添加的用户登录
    def use_new_user_login(self):
        login_data = self.get_table_data("add_user")
        logindata = login_data[1]
        time.sleep(2)
        self.loginElem.login(logindata)

    u'''运维管理员登录'''

    def sso_user_login(self, rowList):
        login_data = self.get_table_data("add_user")
        logindata = login_data[rowList]
        time.sleep(1)
        self.loginElem.login(logindata)

    u'''运维管理员AD域方式登录'''

    def sso_user_ad_login(self, rowList):
        login_data = self.get_table_data("add_user")
        logindata = login_data[rowList]
        self.frameElem.switch_to_content()
        self.loginElem.set_login_method(logindata[2])
        self.loginElem.set_ad_login_username(logindata[3])
        self.loginElem.set_ad_login_pwd(logindata[11])
        time.sleep(1)
        self.loginElem.click_login_button()

    u'''添加认证配置'''

    def add_meth_method(self):
        meth_data = self.get_table_data("meth_method")
        methData = meth_data[1]

        self.switch_to_moudle(u"策略配置", u"认证强度")

        self.authElem.select_all_auth(methData)

    u'''会话配置,设置最大登录数'''

    def set_login_max_num(self):
        self.loginElem.set_max_login_count()

    u'''添加登录测试数据'''

    def add_login_data(self):
        rowList = [2, 3, 4, 5, 6, 7]
        self.add_user_data_module(rowList)

    u'''添加授权用户'''

    def add_authorization_user(self):
        rowList = [8, 9, 10, 11, 12]
        self.add_user_data_module(rowList)

    u'''添加应用发布用户'''

    def add_app_user(self):
        rowList = [3]
        self.add_user_data_module(rowList)

    u'''添加单点登录用户'''

    def add_sso_user(self):
        rowList = [6, 8, 9, 10, 11, 13]
        self.add_user_data_module(rowList)

    u'''添加部门'''

    def add_dep(self, rowList):
        dep_data = self.get_table_data("add_dep")
        for dataRow in rowList:
            data = dep_data[dataRow]
            if dataRow != 0:
                self.set_dep(data)

    u'''删除部门'''

    def del_dep(self, rowList):
        dep_data = self.get_table_data("del_dep")
        for dataRow in rowList:
            data = dep_data[dataRow]
            if dataRow != 0:
                self.set_del_dep(data)

    u'''增加资源数据模板'''

    def add_resource_modele(self, rowList):
        res_data = self.get_table_data("add_res")
        for dataRow in rowList:
            data = res_data[dataRow]
            if dataRow != 0:
                self.set_resource_info(data)

    u'''添加授权资源'''

    def add_resource(self):
        rowList = [1, 2]
        self.add_resource_modele(rowList)

    u'''添加sso资源'''

    def add_sso_resource(self):
        #rowList = [1,2,3,4,5,7,8]
        rowList = [1, 3, 4, 5]
        self.add_resource_modele(rowList)

    u'''添加依附操作系统'''

    def add_database_resource(self):
        rowList = [2]
        self.add_resource_modele(rowList)

    u'''添加资源账号数据模板'''

    def add_res_account_module(self, rowList):
        account_data = self.get_table_data("res_account")
        for dataRow in rowList:
            data = account_data[dataRow]
            if dataRow != 0:
                self.set_res_account(data)

    u'''添加授权资源账号'''

    def add_res_account(self):
        rowList = [1, 3]
        self.add_res_account_module(rowList)

    u'''添加sso资源账号'''

    def add_sso_res_account(self):
        rowList = [1, 2, 4, 5, 6, 7]
        #rowList = [1,2,3,4,5,6,7,9,10]
        self.add_res_account_module(rowList)

    u'''添加用户组'''

    def add_user_group(self, rowList):
        user_group_data = self.get_table_data("add_user_group")
        for dataRow in rowList:
            data = user_group_data[dataRow]
            if dataRow != 0:
                self.set_add_user_group(data)

    u'''删除用户组'''

    def del_user_group(self, rowList):
        user_group_data = self.get_table_data("del_user_group")
        for dataRow in rowList:
            data = user_group_data[dataRow]
            if dataRow != 0:
                self.set_del_user_group(data)

    u'''添加资源组'''

    def add_res_group(self, rowList):
        res_group_data = self.get_table_data("add_res_group")
        for dataRow in rowList:
            data = res_group_data[dataRow]
            if dataRow != 0:
                self.set_add_res_group(data)

    u'''删除资源组'''

    def del_res_group(self, rowList):
        res_group_data = self.get_table_data("del_res_group")
        for dataRow in rowList:
            data = res_group_data[dataRow]
            if dataRow != 0:
                self.set_del_res_group(data)

    u'''添加授权'''

    def add_authrization(self, rowList):
        auth_data = self.get_table_data("add_authorization")
        for dataRow in rowList:
            data = auth_data[dataRow]
            if dataRow != 0:
                self.set_authorization(data)

    u'''添加授权数据模板'''

    def add_authorization_module(self, rowList):
        autho_data = self.get_table_data("add_account_auth")
        for dataRow in rowList:
            data = autho_data[dataRow]
            if dataRow != 0:
                self.set_authorization_info(data)
                self.authorizationElem.back_button()

    u'''添加单点登录授权'''

    def add_sso_authorization(self):
        rowList = [1]
        #rowList = [1,2,3,4,5,6,7]
        self.add_authorization_module(rowList)

    u'''单点登录模板'''

    def sso_module(self, rowList):
        sso_data = self.get_table_data("sso")
        for dataRow in rowList:
            data = sso_data[dataRow]
            if dataRow != 0:
                self.frameElem.from_frame_to_otherFrame("rigthFrame")
                self.ssoElem.select_account(data[0], data[1])
                self.ssoElem.select_sso_icon(data[0], data[2])
                if data[3] != "":
                    self.ssoElem.select_protocol(data[3])
                #self.ssoElem.execute_chrome_key()
                self.ssoElem.choice_browser(data[2], data[4], data[5], data[6])

    u'''添加客户端数据模板'''

    def add_client_module(self, rowList):
        client_data = self.get_table_data("add_client")
        self.switch_to_moudle(u"系统配置", u"客户端配置")
        for dataRow in rowList:
            data = client_data[dataRow]
            if dataRow != 0:
                self.set_client_info(data)

    u'''删除客户端数据模板'''

    def del_client_module(self, rowList):
        client_data = self.get_table_data("del_client")
        self.switch_to_moudle(u"系统配置", u"客户端配置")
        for dataRow in rowList:
            data = client_data[dataRow]
            if dataRow != 0:
                self.set_delete_client_info(data)

    u'''添加数据库资源模板'''

    def add_database_res_module(self, rowList):
        database_data = self.get_table_data("add_database")
        for dataRow in rowList:
            data = database_data[dataRow]
            if dataRow != 0:
                self.set_database_res_info(data)

    u'''删除用户数据模板'''

    def del_user_data_module(self, rowList):
        self.switch_to_moudle(u"运维管理", u"用户")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        user_data = self.get_table_data("add_user")
        for dataRow in rowList:
            data = user_data[dataRow]
            if dataRow != 0:
                self.switch_to_moudle(u"运维管理", u"用户")
                self.userElem.operate_delete(data[1])
                self.frameElem.switch_to_content()
                self.cmf.click_login_msg_button()
                self.cmf.click_login_msg_button()

    u'''添加密码策略数据模板'''

    def add_strategy_data_module(self, rowList):
        self.switch_to_moudle(u"策略配置", u"密码策略")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        pwd_data = self.get_table_data("add_strategy")
        for dataRow in rowList:
            data = pwd_data[dataRow]
            if dataRow != 0:
                self.PwdStr.add_pwd_button()
                self.PwdStr.set_pwd_name(data[1])
                self.PwdStr.term_of_validity(data[2])
                self.PwdStr.password_length_min(data[3])
                self.PwdStr.password_length_max(data[4])
                self.PwdStr.set_lower_case(data[5])
                self.PwdStr.set_capital(data[6])
                self.PwdStr.set_minimum_digital(data[7])
                self.PwdStr.set_Minimum_symbol(data[8])
                self.PwdStr.save_button()
                self.frameElem.switch_to_content()
                self.cmf.click_msg_button(1)
                self.PwdStr.return_button()

    u'''删除密码策略数据模板'''

    def del_strategy_data_module(self, rowList):
        self.switch_to_moudle(u"策略配置", u"密码策略")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        pwd_data = self.get_table_data("add_strategy")
        for dataRow in rowList:
            data = pwd_data[dataRow]
            if dataRow != 0:
                self.PwdStr.del_sing_strategy(data[1])
                self.frameElem.switch_to_content()
                self.cmf.click_login_msg_button()
                self.cmf.click_login_msg_button()

    u'''删除资源数据模板'''

    def del_resource_modele(self, rowList):
        self.switch_to_moudle(u"运维管理", u"资源")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        res_data = self.get_table_data("add_res")
        for dataRow in rowList:
            data = res_data[dataRow]
            if dataRow != 0:
                self.resource.click_del_button(data[1])
                self.frameElem.switch_to_content()
                self.cmf.click_login_msg_button()
                self.cmf.click_login_msg_button()

    u'''删除授权数据模板'''

    def del_authorization_module(self, rowList):
        self.switch_to_moudle(u'运维管理', u'授权')
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        autho_data = self.get_table_data("add_account_auth")
        for dataRow in rowList:
            data = autho_data[dataRow]
            if dataRow != 0:
                self.authorizationElem.click_auth_checkbox(data[2])
                self.authorizationElem.del_button()
                self.frameElem.switch_to_content()
                self.cmf.click_login_msg_button()
                self.cmf.click_login_msg_button()

#-------------------------------添加涉密版用户前置条件---------------------------------------

    u'''前置条件通用'''
    def secret_user_prefix_condition(self):
        self.isomper_login()
        self.switch_to_moudle(u'角色管理', u'角色定义')

#------------------------------部门前置条件-----------------------------------

    def depart_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到组织定义
        self.switch_to_moudle(u"运维管理", u"组织定义")

#------------------------------资源组前置条件-----------------------------------

    def regroup_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([9, 6])
        self.user_quit()
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到组织定义
        self.switch_to_moudle(u"运维管理", u"组织定义")

    def regroup_module_post_condition(self):
        self.user_quit()
        #使用安全保密管理员登录
        self.login_secadmin()
        #删除资源
        self.del_resource_modele([9, 6])
        self.user_quit()

#------------------------------用户组前置条件-----------------------------------

    def usergroup_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #添加用户
        self.add_user_data_module([5, 6, 7, 8])
        #切换到组织定义
        self.switch_to_moudle(u"运维管理", u"组织定义")

    def usergroup_module_post_condition(self):
        self.del_user_data_module([5, 6, 7, 8])
        self.user_quit()

#------------------------------NTP服务前置条件---------------------------------

    def ntp_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到NTP服务
        self.switch_to_moudle(u'系统配置', u'关联服务')
        self.ntp.click_left_moudle(0)

#-------------------------------SYSLOG前置条件---------------------------------

    def syslog_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到NTP服务
        self.switch_to_moudle(u'系统配置', u'关联服务')
        self.ntp.click_left_moudle(1)

#------------------------------邮件前置条件---------------------------------

    def mail_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到邮件服务
        self.switch_to_moudle(u'系统配置', u'关联服务')
        self.mail.click_left_moudle_test()

#------------------------------密码信封前置条件---------------------------------

    def passwd_envelope_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到邮件服务
        self.switch_to_moudle(u'系统配置', u'关联服务')
        self.passwdenvelope.click_left_moudle_envelope()

#-------------------------------应用发布后置条件-------------------------------

    def application_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        self.add_user_data_module([9, 10])
        self.switch_to_moudle(u"系统配置", u"关联服务")

    def application_module_post_condition(self):
        self.del_user_data_module([9, 10])
        self.user_quit()

#-------------------------------网卡配置前置条件-------------------------------

    def network_card_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到网卡配置
        self.switch_to_moudle(u'系统配置', u'网络配置')

#-------------------------------路由配置前置条件-------------------------------

    def routing_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到路由配置
        self.cmf.select_menu(u'系统配置', u'网络配置', u'路由配置')

#------------------------------备份还原前置条件-----------------------------------

    def backup_restore_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()

#-----------------------------客户端配置前置条件------------------------------

    def client_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        self.switch_to_moudle(u"系统配置", u"客户端配置")

#-----------------------------AD域抽取前置条件------------------------------

    def ad_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        self.add_user_data_module([18])
        self.switch_to_moudle(u"系统配置", u"AD定时抽取")

    u'''AD域抽取后置条件'''

    def ad_module_post_condition(self):
        self.del_user_data_module([18])
        self.user_quit()

#------------------------------使用授权前置条件---------------------------------

    def use_auth_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        self.switch_to_moudle(u'系统配置', u'使用授权')

#------------------------------用户模块前置条件--------------------------------

    u'''用户模块前置条件'''
    def user_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        self.switch_to_moudle(u'运维管理', u'用户')

#--------------------------认证方式前置条件------------------------------------

    u'''认证方式前置条件'''
    def auth_method_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        self.add_user_data_module([11])
        self.switch_to_moudle(u"策略配置", u"认证强度")
        self.frameElem.from_frame_to_otherFrame("mainFrame")

    u'''认证方式后置条件'''

    def auth_method_post_condition(self):
        self.del_user_data_module([11])
        self.user_quit()

#---------------------------------登录模块前置条件-----------------------------

    u'''登录模块前置条件'''
    def login_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #配置认证方式
        self.add_meth_method()
        #配置最大登录数
        self.set_login_max_num()
        #添加登录用户数据
        self.add_user_data_module([12, 13, 14, 15, 16, 17])
        #改变a的状态为关
        self.userElem.change_user_status_off("gyrlogin2")
        #系统管理员退出
        self.user_quit()

    u'''登录模块后置条件'''

    def login_module_post_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #删除认证方式
        self.authElem.del_auth_method()
        self.del_user_data_module([12, 13, 14, 15, 16, 17])
        self.user_quit()

#------------------------------告警策略前置条件---------------------------------

    def alarm_strategy_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()

    def alarm_strategy_module_post_condition(self):
        self.alarm.del_command_config()
        self.alarm.del_default_config()
        self.alarm.del_auth_config()
        self.user_quit()

#------------------------------会话配置前置条件--------------------------------

    def session_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        self.switch_to_moudle(u"策略配置", u"会话配置")

#------------------------------密码策略前置条件--------------------------------

    def pwdstr_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([14])
        self.add_user_data_module([19])
        self.switch_to_moudle(u"策略配置", u"密码策略")

    def pwdstr_module_post_condition(self):
        self.del_resource_modele([14])
        self.del_user_data_module([19])
        self.user_quit()

#------------------------------linux资源前置条件-----------------------------------

    def linuxre_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #添加密码策略
        self.add_strategy_data_module([1])
        #切换到资源
        self.switch_to_moudle(u"运维管理", u"资源")

    def linuxre_module_post_condition(self):
        #删除密码策略
        self.del_strategy_data_module([1])
        self.user_quit()

#------------------------------network资源前置条件-----------------------------------

    def networkre_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #切换到资源
        self.switch_to_moudle(u"运维管理", u"资源")

#------------------------------windows资源前置条件-----------------------------------

    def windowre_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #添加密码策略
        self.add_strategy_data_module([2])
        #切换到资源
        self.switch_to_moudle(u"运维管理", u"资源")

    def windowre_module_post_condition(self):
        #删除密码策略
        self.del_strategy_data_module([2])
        self.user_quit()

#-----------------------------数据库前置条件----------------------------------

    def database_resource_prefix_condition(self):
        self.login_sysadmin()
        #添加应用发布
        self.add_application([1])
        self.user_quit()
        #使用安全保密管理员登录
        self.login_secadmin()
        self.add_resource_modele([17])
        self.switch_to_moudle(u"运维管理", u"资源")

    def database_resource_post_condition(self):
        self.del_resource_modele([17])
        self.user_quit()
        self.login_sysadmin()
        self.del_application([1])
        self.user_quit()

#------------------------------授权前置条件-----------------------------------

    def authori_module_prefix_condition(self):

        #使用安全保密管理员登录
        self.login_secadmin()
        self.add_resource_modele([15, 16])
        self.add_res_account_module([18, 19])
        self.user_quit()
        self.login_sysadmin()
        #添加授权用户
        self.add_user_data_module([20, 21, 22, 23, 24])
        self.add_res_group([1])
        self.add_user_group([1])
        self.user_quit()
        self.login_secadmin()
        self.switch_to_moudle(u'运维管理', u'授权')

    def authori_module_post_condition(self):

        self.del_resource_modele([15, 16])
        self.user_quit()
        self.login_sysadmin()
        self.del_res_group([1])
        self.del_user_group([1])
        self.del_user_data_module([20, 21, 22, 23, 24])
        self.user_quit()

#------------------------------命令规则前置条件-----------------------------------

    def commandrule_module_prefix_condition(self):
        self.login_sysadmin()
        #添加用户
        self.add_user_data_module([25])
        self.user_quit()
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([3])
        #添加资源账号
        self.add_res_account_module([4])
        #添加授权
        self.add_authorization_module([2])
        #切换到规则定义
        self.switch_to_moudle(u'运维管理', u'规则定义')
        self.command.click_left_rule(0)

    def commandrule_module_post_condition(self):
        #删除授权
        self.del_authorization_module([2])
        #删除资源
        self.del_resource_modele([3])
        self.user_quit()
        self.login_sysadmin()
        #删除用户
        self.del_user_data_module([25])
        self.user_quit()

#------------------------------时间规则前置条件-----------------------------------

    def timerule_module_prefix_condition(self):
        self.login_secadmin()
        #添加用户
        self.add_user_data_module([26, 27, 28, 29, 30])
        #切换到规则定义
        self.switch_to_moudle(u'运维管理', u'规则定义')
        self.command.click_left_rule(1)

    def timerule_module_post_condition(self):
        #删除用户
        self.del_user_data_module([26, 27, 28, 29, 30])
        self.user_quit()

#------------------------------地址规则前置条件-----------------------------------

    def addressrule_module_prefix_condition(self):
        self.login_secadmin()
        #添加用户
        self.add_user_data_module([31, 32, 33, 34, 35, 36, 37, 38])
        #切换到规则定义
        self.switch_to_moudle(u'运维管理', u'规则定义')
        self.command.click_left_rule(2)

    def addressrule_module_post_condition(self):
        self.del_user_data_module([31, 32, 33, 34, 35, 36, 37, 38])
        self.user_quit()

#------------------------------资源时间规则前置条件-----------------------------------

    def retimerule_module_prefix_condition(self):
        self.login_sysadmin()
        #添加用户
        self.add_user_data_module([39])
        self.user_quit()
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([4, 5, 10])
        #添加资源账号
        self.add_res_account_module([5, 6, 14])
        self.add_authorization_module([6])
        #切换到规则定义
        self.switch_to_moudle(u'运维管理', u'规则定义')
        self.command.click_left_rule(3)

    def retimerule_module_post_condition(self):
        self.user_quit()
        self.login_sysadmin()
        #删除用户
        self.del_user_data_module([39])
        self.user_quit()
        self.login_secadmin()
        #删除资源
        self.del_resource_modele([4, 5, 10])
        #删除授权
        self.del_authorization_module([6])
        self.user_quit()

#------------------------------流程前置条件-----------------------------------

    def process_module_prefix_condition(self):
        self.login_sysadmin()
        #添加用户
        self.add_user_data_module([40, 41, 42, 43, 44])
        self.user_quit()
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([11, 12])
        #添加资源账号
        self.add_res_account_module([15, 16])
        self.add_authrization([1])

    def process_module_post_condition(self):
        #删除授权
        self.del_authorization_module([7])
        #删除资源
        self.del_resource_modele([11, 12])
        self.user_quit()
        self.login_sysadmin()
        #删除用户
        self.del_user_data_module([40, 41, 42, 43, 44])
        self.user_quit()

#------------------------------双人授权前置条件-----------------------------------

    def dualmandate_module_prefix_condition(self):
        self.login_sysadmin()
        #添加用户
        self.add_user_data_module([45, 46])
        self.user_quit()
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([13])
        #添加资源账号
        self.add_res_account_module([17])
        #添加授权
        self.add_authrization([4])

    def dualmandate_module_post_condition(self):
        #删除授权
        self.del_authorization_module([8])
        #删除资源
        self.del_resource_modele([13])
        self.user_quit()
        self.login_sysadmin()
        #删除用户
        self.del_user_data_module([45, 46])
        self.user_quit()

#-----------------------------行为报表前置条件---------------------------------

    def opt_report_module_prefix_condition(self):
        self.login_secadmin()
        self.add_resource_modele([18])
        self.user_quit()
        self.login_sysadmin()
        self.add_user_data_module([47])
        self.add_res_group([2])
        self.add_user_group([2])
        self.user_quit()
        self.login_sysaudit()
        self.switch_to_moudle(u"报表管理", u"审计报表")

    def opt_report_module_post_condition(self):
        self.user_quit()
        self.login_secadmin()
        self.del_resource_modele([18])
        self.user_quit()
        self.login_sysadmin()
        self.del_user_data_module([47])
        self.del_res_group([2])
        self.del_user_group([2])
        self.user_quit()

#-----------------------------配置报表前置条件---------------------------------

    def conf_report_module_prefix_condition(self):
        self.login_sysadmin()
        self.add_user_data_module([48])
        self.add_user_group([3])
        self.user_quit()
        self.login_sysaudit()
        self.switch_to_moudle(u"报表管理", u"审计报表")

    def conf_report_module_post_condition(self):
        self.user_quit()
        self.login_sysadmin()
        self.del_user_data_module([48])
        self.del_user_group([3])
        self.user_quit()

#-----------------------------配置审计前置条件------------------------------

    def system_log_prefix_condition(self):
        self.login_sysadmin()
        self.add_user_data_module([49])
        self.switch_to_moudle(u"系统配置", u"关联服务")
        self.ntp.click_left_moudle(1)
        #填写syslog信息
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        self.syslog.set_ip("172.16.10.11")
        self.syslog.set_ident("aa")
        self.syslog.save_button()
        self.cmf.click_login_msg_button()
        self.user_quit()
        self.login_sysaudit()
        self.switch_to_moudle(u"审计管理", u"配置审计")

    def system_log_post_condition(self):
        self.user_quit()
        self.login_sysadmin()
        self.del_user_data_module([49])
        self.user_quit()

#-----------------------------运维审计前置条件------------------------------

    def audit_log_prefix_condition(self):
        self.login_and_switch_to_dep()
        self.add_user_data_module([43])
        self.add_resource_modele([22])
        self.add_res_account_module([20])
        self.add_authorization_module([9])
        self.switch_to_operation()
        self.sso_module([1])
        self.user_quit()
        #新添加的运维管理员登录
        self.sso_user_login(43)
        self.sso_module([1])
        #新添加的运维管理员退出
        self.user_quit()
        self.login_and_switch_to_sys()
        self.switch_to_moudle(u"审计管理", u"运维审计")

    def audit_log_post_condition(self):
        self.sys_switch_to_dep()
        self.del_authorization_module([9])
        self.del_resource_modele([22])
        self.del_user_data_module([43])
        self.user_quit()

#------------------------------命令单点登录前置条件----------------------------

    u'''单点登录前置条件'''
    def sso_prefix_condition(self):
        self.login_and_switch_to_dep()
        self.add_resource_modele([1, 3, 4, 5])
        self.add_res_account_module([1, 2, 4, 5, 6, 7])
        self.add_authorization_module([1])
        self.switch_to_operation()
        #self.user_quit()
        #self.login_and_switch_to_common()

    u'''单点登录后置条件'''

    def sso_post_condition(self):
        self.user_quit()
        self.login_and_switch_to_dep()
        self.del_resource_modele([1, 3, 4, 5])
        self.del_authorization_module([1])
        self.user_quit()

#------------------------------windows单点登录前置条件-------------------------

    u'''windows单点登录前置条件'''
    def windows_sso_prefix_condition(self):
        self.login_and_switch_to_sys()
        #配置认证方式
        self.add_meth_method()
        self.add_user_data_module([42])
        self.sys_switch_to_dep()
        #self.login_and_switch_to_dep()
        self.add_resource_modele([2, 7, 8])
        self.add_res_account_module([3, 9, 10])
        self.add_authorization_module([3, 4])
        self.switch_to_operation()
        #self.user_quit()
        #self.login_and_switch_to_common()

    u'''单点登录后置条件'''

    def windows_sso_post_condition(self):
        self.user_quit()
        self.login_and_switch_to_dep()
        self.del_authorization_module([3, 4])
        self.del_user_data_module([42])
        self.del_resource_modele([8, 7, 2])
        self.user_quit()

#------------------------------数据库单点登录前置条件-------------------------

    u'''数据库单点登录前置条件'''
    def database_sso_prefix_condition(self):
        #使用公共用户登录系统
        self.login_and_switch_to_sys()
        #添加应用发布
        self.add_application([2])
        #添加客户端
        self.add_client_module([1, 2])
        self.sys_switch_to_dep()
        self.add_database_res_module([1, 2, 3])
        self.add_res_account_module([11, 12, 13])
        self.add_authorization_module([5])
        self.switch_to_operation()

    u'''数据库单点登录后置条件'''

    def database_sso_post_condition(self):
        self.user_quit()
        self.login_and_switch_to_dep()
        self.del_authorization_module([5])
        self.del_resource_modele([19, 20, 21])
        self.dep_switch_to_sys()
        self.del_application([2])
        self.del_client_module([1, 2])
        self.user_quit()
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))