def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.command = CommandRule(driver) self.log = log()
def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cmf = commonFun(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.user = UserPage(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)
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)
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)
def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.command = CommandRule(driver) self.log = log()
def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cmf = commonFun(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.user = UserPage(driver)
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)
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)
class Dobapproval(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cmf = commonFun(driver) self.log = log() self.cnEn = cnEncode() self.depart = Department(driver) self.loginElem = loginPage(self.driver) self.authElem = AuthorizationPage(self.driver) self.acproval = Accapproval(driver) u'''点击授权操作列双人授权按钮 parameters: name : 授权名称 ''' def click_double_license_button(self, name): self.frameElem.from_frame_to_otherFrame("mainFrame") self.authElem.operate_double_approval(name) u'''点击双人审批图标 parameters : rename : 资源名称 ''' def click_double_license_icon(self, rename): self.frameElem.from_frame_to_otherFrame("rigthFrame") rname = self.cnEn.is_float(rename) row = self.acproval.select_resoure_sso(rname) xpath = "/html/body/div[1]/div[7]/div[2]/div/table/tbody/tr[" + str( row * 2) + "]/td/div/table/tbody/tr/td[2]/a/img" time.sleep(2) self.getElem.find_element_wait_and_click_EC("xpath", xpath) time.sleep(2) u'''校验图标 parameters : - rename:资源名称 ''' def check_ico_len(self, rename): self.frameElem.from_frame_to_otherFrame("rigthFrame") time.sleep(3) row = self.acproval.select_resoure_sso(rename) self.acproval.click_refresh_icon(rename) ico_xpath = "/html/body/div[1]/div[7]/div[2]/div[1]/table/tbody/tr[" + str( row * 2) + "]/td/div/table/tbody/tr/td[2]" time.sleep(2) selem = self.getElem.find_element_with_wait_EC("xpath", ico_xpath) selems = selem.find_elements_by_tag_name("a") lengh = len(selems) if lengh > 1: self.log.log_detail(u"双人授权已同意申请,可以进行单点登录", True) else: self.log.log_detail(u"双人授权已拒绝申请,不可以进行单点登录", True) u'''选择授权人 parameters : - authorizer:授权人名称 ''' def select_authorizer(self, authorizer): self.frameElem.switch_to_artIframe() author = self.cnEn.is_float(authorizer) selem = self.getElem.find_element_with_wait_EC("id", "fortApproverId") self.selectElem.select_element_by_visible_text(selem, author) u'''勾选同终端直接输入口令访问''' def check_same_termina(self): self.frameElem.switch_to_artIframe() self.getElem.find_element_wait_and_click_EC("id", "fortIsRemoteApply") u'''填写授权人密码 Parameters: - passwd:授权人密码 ''' def set_authorizer_pwd(self, passwd): self.frameElem.switch_to_artIframe() pwd = self.cnEn.is_float(passwd) self.getElem.find_element_wait_and_clear("id", "password") self.getElem.find_element_wait_and_sendkeys("id", "password", pwd) u'''调用新浏览器''' def call_other_browsers(self): newbrowser = webdriver.Ie() # newbrowser = webdriver.Chrome() #IE窗口最大化 newbrowser.maximize_window() newbrowser.get("https://172.16.10.155") newbrowser.get("javascript:document.getElementById('overridelink').click();") return newbrowser u'''远程用户登录 Parameters: - listusers:用户集 ''' def user_remote_approval(self, newbrowser, listusers): users = listusers.split() newbrowser.switch_to_default_content() selem = newbrowser.find_element_by_id("loginMethod") Select(selem).select_by_value(users[0]) newbrowser.find_element_by_id("username").click() newbrowser.find_element_by_id("username").send_keys(users[1]) newbrowser.find_element_by_id("pwd").click() newbrowser.find_element_by_id("pwd").send_keys(users[2]) time.sleep(1) newbrowser.find_element_by_id("do_login").click() u'''菜单选择 Parameters: - newbrowser:新浏览器驱动 - levelText1:1级菜单文本 - levelText2:2级菜单文本 - levelText3:3级菜单文本 ''' def click_menu(self,newbrowser, levelText1, levelText2='no',levelText3='no'): self.remote_break_frame(newbrowser, "topFrame") #点击一级菜单 newbrowser.find_element_by_link_text(levelText1).click() time.sleep(1) #如果有2级菜单,再点击2级菜单 if levelText2 != 'no': newbrowser.find_element_by_link_text(levelText2).click() #如果有3级菜单,根据名称点击3级菜单 if levelText3 != 'no': self.remote_break_frame(newbrowser, "leftFrame") newbrowser.find_element_by_link_text(levelText3).click() u'''判断名称是否存在 Parameters: - namevalue:传入的要被查询名称 - name:表格列的name属性 return:true代表存在,false代表不存在 ''' def namevalue_remote_is_exsit(self, newbrowser,namevalue, name): nameval = self.cnEn.is_float(namevalue) namesex = self.cnEn.is_float(name) isExsit = False text_list = newbrowser.find_elements_by_name(namesex) for fortNameValue in text_list: fortNameValue_text = fortNameValue.text if fortNameValue_text == nameval: isExsit = True break return isExsit u'''查询已存在名称位于第几行 Parameters: - namevalue:传入的要被查询名称 - name:表格列的name属性 return:定位该名称位于第几行 ''' def find_name_remote_by_row(self, newbrowser, namevalue, name): self.remote_break_frame(newbrowser, "mainFrame") nameval = self.cnEn.is_float(namevalue) namesex = self.cnEn.is_float(name) row = 0 if self.namevalue_remote_is_exsit(newbrowser,nameval, namesex): text_list = newbrowser.find_elements_by_name(namesex) for fortNameValue in text_list: row = row + 1 fortNameValue_text = fortNameValue.text if fortNameValue_text == nameval: break return row u'''通过流程号点击要审批的信息 Parameters: - number:流程号 ''' def click_remote_approval_by_number(self, newbrowser, number): row = self.find_name_remote_by_row(newbrowser, number, "fortProcessInstanceId") xpath = "/html/body/form/div/div[7]/div[2]/div/table/tbody/tr[" + str(row) + "]/td[8]/input[1]" newbrowser.find_element_by_xpath(xpath).click() u'''流程控制是否同意审批 Parameters: - status:1代表同意审批,2代表拒绝审批 ''' def process_remote_is_agree_approval(self, newbrowser, status): statu = self.cnEn.is_float(status) self.remote_break_frame(newbrowser, "mainFrame") if statu == '1': newbrowser.find_element_by_id("yes").click() elif statu == '2': newbrowser.find_element_by_id("no").click() u'''填写流程控制中审批申请单的描述 Parameters: - description:描述内容 ''' def set_process_remote_description(self, newbrowser, description): descri = self.cnEn.is_float(description) self.remote_break_frame(newbrowser, "mainFrame") newbrowser.find_element_by_id("fortApprovalOpinions").clear() newbrowser.find_element_by_id("fortApprovalOpinions").send_keys(descri) u'''点击提交按钮''' def click_remote_submit(self, newbrowser): self.remote_break_frame(newbrowser, "mainFrame") newbrowser.find_element_by_id("save_process_approval").click() u'''点击确定按钮''' def click_remote_msg_button(self, newbrowser): newbrowser.switch_to_default_content() OKBTN = "//div[@id='aui_buttons']/button[1]" newbrowser.find_element_by_xpath(OKBTN).click() u'''点击返回按钮''' def remote_back(self, newbrowser): self.remote_break_frame(newbrowser, "mainFrame") newbrowser.find_element_by_id("history_skip").click() u'''跳转frame Parameters: - frameName:要跳转到的frame的名字 ''' def remote_break_frame(self, newbrowser, frameName): newbrowser.switch_to_default_content() newbrowser.switch_to_frame("content1") newbrowser.switch_to_frame(frameName) u'''点击退出''' def remote_quit(self,newbrowser): self.remote_break_frame(newbrowser, "topFrame") time.sleep(1) newbrowser.find_element_by_id("logout").click() u'''申请人发送双人审批申请 Parameters: - data:excel中的一行数据 ''' def send_double_license_applicant(self, data): self.acproval.select_resoure_account(data[1], data[2]) self.click_double_license_icon(data[1]) self.select_authorizer(data[3]) if data[4] != 'no': self.check_same_termina() self.set_authorizer_pwd(data[4]) self.acproval.set_operation_description(data[5]) self.acproval.click_sure_button() self.driver.implicitly_wait(10) self.log.log_detail(data[0], True) u'''审批人通过当前浏览器流程控制进行审批 Parameters: - number:流程号 ''' def approver_by_process_approval(self, expData, number): xpathMsg = ".//*[@id='body1']/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div" #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(expData)): data = expData[dataRow] try: #如果不是第1行,读取数据 if dataRow != 0: self.acproval.user_login(data[2]) self.frameElem.from_frame_to_otherFrame("topFrame") self.cmf.select_menu(u"流程控制", u"流程任务") self.acproval.click_approval_by_number(number) if data[1] != 'no': self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", xpathMsg, data, flag) else: self.acproval.process_is_agree_approval(data[3]) self.acproval.set_process_apply_description(data[4]) self.acproval.click_submit() self.cmf.click_login_msg_button() self.acproval.back_quit_common() except Exception as e: print ("expired_approvel fail:" + str(e)) u'''审批人通过新开启的浏览器流程控制进行审批 Parameters: - number:流程号 ''' def approver_remote_approval(self, expData, number): for dataRow in range(len(expData)): data = expData[dataRow] try: #如果不是第1行,读取数据 if dataRow != 0: newbrowser = self.call_other_browsers() self.user_remote_approval(newbrowser, data[1]) self.click_menu(newbrowser, u"流程控制", u"流程任务") self.click_remote_approval_by_number(newbrowser, number) self.process_remote_is_agree_approval(newbrowser, data[2]) self.set_process_remote_description(newbrowser, data[3]) self.click_remote_submit(newbrowser) self.click_remote_msg_button(newbrowser) self.remote_back(newbrowser) self.driver.implicitly_wait(5) self.remote_quit(newbrowser) newbrowser.quit() except Exception as e: print ("expired_approvel fail:" + str(e))
class AddressRule(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cmf = commonFun(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.user = UserPage(driver) u'''点击批量删除''' def click_bulkdel_address(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "delete_rule_address") u'''点击编辑按钮 Parameters: - addressname:地址规则名称 ''' def click_edit_address(self, addressname): try: self.frameElem.from_frame_to_otherFrame("rigthFrame") row = self.acproval.find_name_by_row(addressname, "fortRuleAddressName") update_xpath = ".//*[@id='content_table']/tbody/tr[" + str(row) + "]/td[5]/input[1]" time.sleep(3) self.getElem.find_element_wait_and_click("xpath", update_xpath) except Exception: print("Click the Edit button to fail") u'''点击删除按钮 Parameters: - addressname:时间规则名称 ''' def click_del_address(self, addressname): try: self.frameElem.from_frame_to_otherFrame("rigthFrame") row = self.acproval.find_name_by_row(addressname, "fortRuleAddressName") del_xpath = ".//*[@id='content_table']/tbody/tr[" + str(row) + "]/td[5]/input[2]" self.getElem.find_element_wait_and_click("xpath", del_xpath) except Exception: print("Click the Del button to fail") u'''填写检索名称 Parameters: - addressname:名称 ''' def set_search_addressname(self, addressname): self.frameElem.from_frame_to_otherFrame("rigthFrame") name = self.cnEn.is_float(addressname) self.getElem.find_element_wait_and_clear("id", "rule_address_id") self.getElem.find_element_wait_and_sendkeys("id", "rule_address_id", name) u'''点击检索按钮''' def click_search_address(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "rule_address") u'''填写地址规则名称 Parameters: - rulename:规则名称 ''' def set_rulename(self, rulename): name = self.cnEn.is_float(rulename) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "fortRuleAddressName") self.getElem.find_element_wait_and_sendkeys("id", "fortRuleAddressName", name) u'''选择IP规则 Parameters: - stauts:1代表勾选IP掩码,2代表勾选IP区间,3代表IP掩码和IP区间 ''' def checkbox_ip_rule(self, stauts): staut = self.cnEn.is_float(stauts) self.frameElem.from_frame_to_otherFrame("rigthFrame") if staut == '1': self.getElem.find_element_wait_and_click_EC("id", "one_ip") elif staut == '2': self.getElem.find_element_wait_and_click_EC("id", "duo_ip") else: self.getElem.find_element_wait_and_click_EC("id", "one_ip") self.getElem.find_element_wait_and_click_EC("id", "duo_ip") u'''点击增加多个IP''' def click_add_more_ip(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "add_ip_mask") u'''填写ip地址 Parameters: - iplist:所填写的IP列表集合 ''' def set_ip(self, iplist): self.frameElem.from_frame_to_otherFrame("rigthFrame") #获取所有页面IP地址集合 fortips = self.driver.find_elements_by_name("fortIp") ipaddress = iplist.split() self.ip_mask_common(fortips, ipaddress) u'''填写ip地址掩码 Parameters: - masklist:所填写的IP掩码value值列表集合 ''' def set_ip_mask(self, masklist): self.frameElem.from_frame_to_otherFrame("rigthFrame") #获取所有页面IP掩码集合 fortMasks = self.driver.find_elements_by_name("fortMask") masklists = masklist.split() self.ip_mask_common(fortMasks, masklists) u'''填写IP地址和掩码公共方法 Parameters: - ipsets:页面IP段集合 - dataipsets:列表数据集合 ''' def ip_mask_common(self, ipsets, dataipsets): #获取页面集合长度 ipsetth = len(ipsets) fortth = 0 #循环ip掩码进行填写操作 for ipset in ipsets: if fortth < ipsetth and dataipsets[fortth] != 'no': fortips = self.driver.find_elements_by_name("fortIp") if ipsets == fortips: ipset.clear() ipset.send_keys(dataipsets[fortth]) fortth = fortth + 1 u'''点击增加多个IP段''' def click_add_ip_segment(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "add_ip_range") u'''填写起始段IP Parameters: - ipstartlist:所填写的起始段IP列表集合 ''' def set_ip_start(self, ipstartlist): self.frameElem.from_frame_to_otherFrame("rigthFrame") ipstarts = ipstartlist.split() self.ip_segment_common("fortIpStart", ipstarts) u'''填写结束段IP Parameters: - ipendlist:所填写的结束段IP列表集合 ''' def set_ip_end(self, ipendlist): self.frameElem.from_frame_to_otherFrame("rigthFrame") ipends = ipendlist.split() self.ip_segment_common("fortIpEnd", ipends) u'''填写区间段IP公共方法 Parameters: - ipsetname:页面IP段name属性 - dataipsets:列表数据集合 ''' def ip_segment_common(self, ipsetname, dataipsets): #获取所有页面IP段集合 ipsets = self.driver.find_elements_by_name(ipsetname) #获取IP段集合长度 ipsetsth = len(ipsets) fortth = 0 #循环进行段ip填写操作 for ipset in ipsets: if fortth < ipsetsth: ipset.clear() ipset.send_keys(dataipsets[fortth]) fortth = fortth + 1 u'''点击测试''' def click_test(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "test_ip") u'''填写测试ip地址 Parameters: - testip:ip地址 ''' def set_ip_test(self, testip): ip = self.cnEn.is_float(testip) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "testIp") self.getElem.find_element_wait_and_sendkeys("id", "testIp", ip) u'''填写描述信息 Parameters: - description:描述信息 ''' def set_description(self, description): descript = self.cnEn.is_float(description) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "fortDescription") self.getElem.find_element_wait_and_sendkeys("id", "fortDescription", descript) u'''点击保存''' def click_save(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "save_rule_address") u'''点击返回''' def click_back(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "history_skip") u'''给用户添加地址规则 Parameters: - username:要编辑的用户名称 - adrerule:地址规则名称 ''' def edit_user_address_rule(self, username, adrerule): self.frameElem.from_frame_to_otherFrame("mainFrame") name = self.cnEn.is_float(username) self.user.operate_edit(name) self.user.click_advanced_option() self.select_adress_rule(adrerule) self.user.save_button() self.cmf.click_login_msg_button() self.user.click_back_button() u'''选择地址规则 Parameters: - adrerule:地址规则名称 ''' def select_adress_rule(self, adrerule): self.frameElem.from_frame_to_otherFrame("mainFrame") addressrule = self.cnEn.is_float(adrerule) select_elem = self.getElem.find_element_with_wait_EC('id',"fortRuleAddressId") self.selectElem.select_element_by_visible_text(select_elem, addressrule)
class RetimeRule(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.command = CommandRule(driver) self.log = log() u'''点击删除''' def click_bulkdel_retime(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC( "id", "delete_rule_time_resource") u'''选择默认动作 Parameters: - staut:0代表禁止登录,1代表允许登录 ''' def select_default_type(self, state): try: valu = self.cnEn.is_float(state) self.frameElem.from_frame_to_otherFrame("rigthFrame") selem = self.getElem.find_element_with_wait_EC("id", "defaultType") self.selectElem.select_element_by_value(selem, valu) except Exception: print("Select default action failure") u'''点击运行状态''' def click_running_state(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "ruleState") u'''填写每月开始日期 Parameters: - starttime:每月的开始时间 ''' def set_month_start_time(self, starttime): valu = self.cnEn.is_float(starttime) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear_EC("id", "fortMonthStartTime") self.getElem.find_element_wait_and_sendkeys("id", "fortMonthStartTime", valu) u'''填写每月结束日期 Parameters: - endtime:每月的结束时间 ''' def set_month_end_time(self, endtime): valu = self.cnEn.is_float(endtime) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear_EC("id", "fortMonthEndTime") self.getElem.find_element_wait_and_sendkeys("id", "fortMonthEndTime", valu) u'''选择每周开始日期 Parameters: - starttime:每周的开始时间 ''' def set_week_start_time(self, starttime): valu = self.cnEn.is_float(starttime) self.frameElem.from_frame_to_otherFrame("rigthFrame") selem = self.getElem.find_element_with_wait_EC("id", "fortWeekStartTime") self.selectElem.select_element_by_value(selem, valu) u'''选择每周结束日期 Parameters: - endtime:每周的结束时间 ''' def set_week_end_time(self, endtime): valu = self.cnEn.is_float(endtime) self.frameElem.from_frame_to_otherFrame("rigthFrame") selem = self.getElem.find_element_with_wait_EC("id", "fortWeekEndTime") self.selectElem.select_element_by_value(selem, valu) u'''填写每天开始时间 Parameters: - starttime:每天的开始时间 ''' def set_day_start_time(self, starttime): valu = self.cnEn.is_float(starttime) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear_EC("id", "fortDayStartTime") self.getElem.find_element_wait_and_sendkeys("id", "fortDayStartTime", valu) u'''填写每天结束时间 Parameters: - endtime:每天的结束时间 ''' def set_day_end_time(self, endtime): valu = self.cnEn.is_float(endtime) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear_EC("id", "fortDayEndTime") self.getElem.find_element_wait_and_sendkeys("id", "fortDayEndTime", valu) u'''选择动作 Parameters: - staut:0代表禁止登录,1代表允许登录 ''' def select_action(self, state): valu = self.cnEn.is_float(state) self.frameElem.from_frame_to_otherFrame("rigthFrame") if valu == '1': self.getElem.find_element_wait_and_click_EC("id", "ruleTypePass") elif valu == '0': self.getElem.find_element_wait_and_click_EC("id", "ruleTypeDeny") u'''点击保存''' def click_save_retime(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "save_rule_time") u'''填写检索的资源名称 Parameters: - rename:资源名称 ''' def set_query_rename(self, rename): resname = self.cnEn.is_float(rename) self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear_EC("id", "fortResourceName") self.getElem.find_element_wait_and_sendkeys("id", "fortResourceName", resname) u'''勾选某个资源 Parameters: - rename:资源名称 ''' def check_resource(self, rename): self.frameElem.from_frame_to_otherFrame("artIframe") self.set_query_rename(rename) self.command.click_check_resource() self.getElem.find_element_wait_and_click_EC("id", "resource_check_all") self.command.check_sure_button() u'''点击操作的公共方法 parameter: - value:序号 - statu:代表点击的操作,1代表勾选复选框;2代表上移;3代表下移;4代表插入;5代表编辑 ''' def click_option_method(self, value, status): self.frameElem.from_frame_to_otherFrame("rigthFrame") valu = self.cnEn.is_float(value) statu = self.cnEn.is_float(status) # 获取table对象 tableelem = self.getElem.find_element_with_wait_EC( "id", "content_table") # 获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") # 位于第几行 line = 0 # 循环所有tr for trelem in trelems: line += 1 # 找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") # 获取td[2]的文本 tdtext = tds[1].text if tdtext == valu: #勾选复选框 if statu == '1': xpath = ".//*[@id='content_table']/tbody/tr[" + str( line) + "]/td[1]/input[1]" #上移 elif statu == '2': xpath = ".//*[@id='content_table']/tbody/tr[" + str( line) + "]/td[8]/a[1]" #下移 elif statu == '3': xpath = ".//*[@id='content_table']/tbody/tr[" + str( line) + "]/td[8]/a[2]" #插入 elif statu == '4': xpath = ".//*[@id='content_table']/tbody/tr[" + str( line) + "]/td[8]/a[3]" #编辑 elif statu == '5': xpath = ".//*[@id='content_table']/tbody/tr[" + str( line) + "]/td[8]/a[4]" self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''校验资源时间规则结果 parameter: - data:数据集 ''' def check_resource_time_rule(self, data): self.frameElem.from_frame_to_otherFrame("rigthFrame") row = self.acproval.select_resoure_sso(data[1]) xpath = "//*[@id='content_table']/tbody/tr[" + str( row * 2) + "]/td/div/table/tbody/tr/td[2]/a[1]/img" isExsit = self.getElem.is_element_exsit("xpath", xpath) if isExsit == True: self.log.log_detail(data[0], True) else: self.log.log_detail(data[0], True)
class AddressRule(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cmf = commonFun(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.user = UserPage(driver) u'''点击批量删除''' def click_bulkdel_address(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "delete_rule_address") u'''点击编辑按钮 Parameters: - addressname:地址规则名称 ''' def click_edit_address(self, addressname): try: self.frameElem.from_frame_to_otherFrame("rigthFrame") row = self.acproval.find_name_by_row(addressname, "fortRuleAddressName") update_xpath = ".//*[@id='content_table']/tbody/tr[" + str(row) + "]/td[5]/input[1]" time.sleep(3) self.getElem.find_element_wait_and_click("xpath", update_xpath) except Exception: print("Click the Edit button to fail") u'''点击删除按钮 Parameters: - addressname:时间规则名称 ''' def click_del_address(self, addressname): try: self.frameElem.from_frame_to_otherFrame("rigthFrame") row = self.acproval.find_name_by_row(addressname, "fortRuleAddressName") del_xpath = ".//*[@id='content_table']/tbody/tr[" + str(row) + "]/td[5]/input[2]" self.getElem.find_element_wait_and_click("xpath", del_xpath) except Exception: print("Click the Del button to fail") u'''填写检索名称 Parameters: - addressname:名称 ''' def set_search_addressname(self, addressname): self.frameElem.from_frame_to_otherFrame("rigthFrame") name = self.cnEn.is_float(addressname) self.getElem.find_element_wait_and_clear("id", "rule_address_id") self.getElem.find_element_wait_and_sendkeys("id", "rule_address_id", name) u'''点击检索按钮''' def click_search_address(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "rule_address") u'''填写地址规则名称 Parameters: - rulename:规则名称 ''' def set_rulename(self, rulename): name = self.cnEn.is_float(rulename) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "fortRuleAddressName") self.getElem.find_element_wait_and_sendkeys("id", "fortRuleAddressName", name) u'''选择IP规则 Parameters: - stauts:1代表勾选IP掩码,2代表勾选IP区间,3代表IP掩码和IP区间 ''' def checkbox_ip_rule(self, stauts): staut = self.cnEn.is_float(stauts) self.frameElem.from_frame_to_otherFrame("rigthFrame") if staut == '1': self.getElem.find_element_wait_and_click_EC("id", "one_ip") elif staut == '2': self.getElem.find_element_wait_and_click_EC("id", "duo_ip") else: self.getElem.find_element_wait_and_click_EC("id", "one_ip") self.getElem.find_element_wait_and_click_EC("id", "duo_ip") u'''点击增加多个IP''' def click_add_more_ip(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "add_ip_mask") u'''填写ip地址 Parameters: - iplist:所填写的IP列表集合 ''' def set_ip(self, iplist): self.frameElem.from_frame_to_otherFrame("rigthFrame") #获取所有页面IP地址集合 fortips = self.driver.find_elements_by_name("fortIp") ipaddress = iplist.split() self.ip_mask_common(fortips, ipaddress) u'''填写ip地址掩码 Parameters: - masklist:所填写的IP掩码value值列表集合 ''' def set_ip_mask(self, masklist): self.frameElem.from_frame_to_otherFrame("rigthFrame") #获取所有页面IP掩码集合 fortMasks = self.driver.find_elements_by_name("fortMask") masklists = masklist.split() self.ip_mask_common(fortMasks, masklists) u'''填写IP地址和掩码公共方法 Parameters: - ipsets:页面IP段集合 - dataipsets:列表数据集合 ''' def ip_mask_common(self, ipsets, dataipsets): #获取页面集合长度 ipsetth = len(ipsets) fortth = 0 #循环ip掩码进行填写操作 for ipset in ipsets: if fortth < ipsetth and dataipsets[fortth] != 'no': fortips = self.driver.find_elements_by_name("fortIp") if ipsets == fortips: ipset.clear() ipset.send_keys(dataipsets[fortth]) fortth = fortth + 1 u'''点击增加多个IP段''' def click_add_ip_segment(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "add_ip_range") u'''填写起始段IP Parameters: - ipstartlist:所填写的起始段IP列表集合 ''' def set_ip_start(self, ipstartlist): self.frameElem.from_frame_to_otherFrame("rigthFrame") ipstarts = ipstartlist.split() self.ip_segment_common("fortIpStart", ipstarts) u'''填写结束段IP Parameters: - ipendlist:所填写的结束段IP列表集合 ''' def set_ip_end(self, ipendlist): self.frameElem.from_frame_to_otherFrame("rigthFrame") ipends = ipendlist.split() self.ip_segment_common("fortIpEnd", ipends) u'''填写区间段IP公共方法 Parameters: - ipsetname:页面IP段name属性 - dataipsets:列表数据集合 ''' def ip_segment_common(self, ipsetname, dataipsets): #获取所有页面IP段集合 ipsets = self.driver.find_elements_by_name(ipsetname) #获取IP段集合长度 ipsetsth = len(ipsets) fortth = 0 #循环进行段ip填写操作 for ipset in ipsets: if fortth < ipsetsth: ipset.clear() ipset.send_keys(dataipsets[fortth]) fortth = fortth + 1 u'''点击测试''' def click_test(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "test_ip") u'''填写测试ip地址 Parameters: - testip:ip地址 ''' def set_ip_test(self, testip): ip = self.cnEn.is_float(testip) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "testIp") self.getElem.find_element_wait_and_sendkeys("id", "testIp", ip) u'''填写描述信息 Parameters: - description:描述信息 ''' def set_description(self, description): descript = self.cnEn.is_float(description) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "fortDescription") self.getElem.find_element_wait_and_sendkeys("id", "fortDescription", descript) u'''点击保存''' def click_save(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "save_rule_address") u'''点击返回''' def click_back(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "history_skip") u'''给用户添加地址规则 Parameters: - username:要编辑的用户名称 - adrerule:地址规则名称 ''' def edit_user_address_rule(self, username, adrerule): self.frameElem.from_frame_to_otherFrame("mainFrame") name = self.cnEn.is_float(username) self.user.operate_edit(name) self.user.click_advanced_option() self.select_adress_rule(adrerule) self.user.save_button() self.cmf.click_login_msg_button() self.user.click_back_button() u'''选择地址规则 Parameters: - adrerule:地址规则名称 ''' def select_adress_rule(self, adrerule): self.frameElem.from_frame_to_otherFrame("mainFrame") addressrule = self.cnEn.is_float(adrerule) select_elem = self.getElem.find_element_with_wait_EC('id',"fortRuleAddressId") self.selectElem.select_element_by_visible_text(select_elem, addressrule)
class RetimeRule(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.command = CommandRule(driver) self.log = log() u'''点击删除''' def click_bulkdel_retime(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "delete_rule_time_resource") u'''选择默认动作 Parameters: - staut:0代表禁止登录,1代表允许登录 ''' def select_default_type(self, state): try: valu = self.cnEn.is_float(state) self.frameElem.from_frame_to_otherFrame("rigthFrame") selem = self.getElem.find_element_with_wait_EC("id", "defaultType") self.selectElem.select_element_by_value(selem, valu) except Exception: print("Select default action failure") u'''点击运行状态''' def click_running_state(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "ruleState") u'''填写每月开始日期 Parameters: - starttime:每月的开始时间 ''' def set_month_start_time(self, starttime): valu = self.cnEn.is_float(starttime) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear_EC("id", "fortMonthStartTime") self.getElem.find_element_wait_and_sendkeys("id", "fortMonthStartTime", valu) u'''填写每月结束日期 Parameters: - endtime:每月的结束时间 ''' def set_month_end_time(self, endtime): valu = self.cnEn.is_float(endtime) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear_EC("id", "fortMonthEndTime") self.getElem.find_element_wait_and_sendkeys("id", "fortMonthEndTime", valu) u'''选择每周开始日期 Parameters: - starttime:每周的开始时间 ''' def set_week_start_time(self, starttime): valu = self.cnEn.is_float(starttime) self.frameElem.from_frame_to_otherFrame("rigthFrame") selem = self.getElem.find_element_with_wait_EC("id", "fortWeekStartTime") self.selectElem.select_element_by_value(selem, valu) u'''选择每周结束日期 Parameters: - endtime:每周的结束时间 ''' def set_week_end_time(self, endtime): valu = self.cnEn.is_float(endtime) self.frameElem.from_frame_to_otherFrame("rigthFrame") selem = self.getElem.find_element_with_wait_EC("id", "fortWeekEndTime") self.selectElem.select_element_by_value(selem, valu) u'''填写每天开始时间 Parameters: - starttime:每天的开始时间 ''' def set_day_start_time(self, starttime): valu = self.cnEn.is_float(starttime) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear_EC("id", "fortDayStartTime") self.getElem.find_element_wait_and_sendkeys("id", "fortDayStartTime", valu) u'''填写每天结束时间 Parameters: - endtime:每天的结束时间 ''' def set_day_end_time(self, endtime): valu = self.cnEn.is_float(endtime) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear_EC("id", "fortDayEndTime") self.getElem.find_element_wait_and_sendkeys("id", "fortDayEndTime", valu) u'''选择动作 Parameters: - staut:0代表禁止登录,1代表允许登录 ''' def select_action(self, state): valu = self.cnEn.is_float(state) self.frameElem.from_frame_to_otherFrame("rigthFrame") if valu == '1': self.getElem.find_element_wait_and_click_EC("id", "ruleTypePass") elif valu == '0': self.getElem.find_element_wait_and_click_EC("id", "ruleTypeDeny") u'''点击保存''' def click_save_retime(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "save_rule_time") u'''填写检索的资源名称 Parameters: - rename:资源名称 ''' def set_query_rename(self, rename): resname = self.cnEn.is_float(rename) self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear_EC("id", "fortResourceName") self.getElem.find_element_wait_and_sendkeys("id", "fortResourceName", resname) u'''勾选某个资源 Parameters: - rename:资源名称 ''' def check_resource(self, rename): self.frameElem.from_frame_to_otherFrame("artIframe") self.set_query_rename(rename) self.command.click_check_resource() self.getElem.find_element_wait_and_click_EC("id", "resource_check_all") self.command.check_sure_button() u'''点击操作的公共方法 parameter: - value:序号 - statu:代表点击的操作,1代表勾选复选框;2代表上移;3代表下移;4代表插入;5代表编辑 ''' def click_option_method(self, value, status): self.frameElem.from_frame_to_otherFrame("rigthFrame") valu = self.cnEn.is_float(value) statu = self.cnEn.is_float(status) # 获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "content_table") # 获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") # 位于第几行 line = 0 # 循环所有tr for trelem in trelems: line += 1 # 找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") # 获取td[2]的文本 tdtext = tds[1].text if tdtext == valu: #勾选复选框 if statu == '1': xpath = ".//*[@id='content_table']/tbody/tr[" + str(line) + "]/td[1]/input[1]" #上移 elif statu == '2': xpath = ".//*[@id='content_table']/tbody/tr[" + str(line) + "]/td[8]/a[1]" #下移 elif statu == '3': xpath = ".//*[@id='content_table']/tbody/tr[" + str(line) + "]/td[8]/a[2]" #插入 elif statu == '4': xpath = ".//*[@id='content_table']/tbody/tr[" + str(line) + "]/td[8]/a[3]" #编辑 elif statu == '5': xpath = ".//*[@id='content_table']/tbody/tr[" + str(line) + "]/td[8]/a[4]" self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''校验资源时间规则结果 parameter: - data:数据集 ''' def check_resource_time_rule(self, data): self.frameElem.from_frame_to_otherFrame("rigthFrame") row = self.acproval.select_resoure_sso(data[1]) xpath = "//*[@id='content_table']/tbody/tr[" + str(row*2) + "]/td/div/table/tbody/tr/td[2]/a[1]/img" isExsit = self.getElem.is_element_exsit("xpath", xpath) if isExsit == True: self.log.log_detail(data[0], True) else: self.log.log_detail(data[0], True)
class Dobapproval(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cmf = commonFun(driver) self.log = log() self.cnEn = cnEncode() self.depart = Department(driver) self.loginElem = loginPage(self.driver) self.authElem = AuthorizationPage(self.driver) self.acproval = Accapproval(driver) u'''点击授权操作列双人授权按钮 parameters: name : 授权名称 ''' def click_double_license_button(self, name): self.frameElem.from_frame_to_otherFrame("mainFrame") self.authElem.operate_double_approval(name) u'''点击双人审批图标 parameters : rename : 资源名称 ''' def click_double_license_icon(self, rename): self.frameElem.from_frame_to_otherFrame("rigthFrame") rname = self.cnEn.is_float(rename) row = self.acproval.select_resoure_sso(rname) xpath = "/html/body/div[1]/div[7]/div[2]/div/table/tbody/tr[" + str( row * 2) + "]/td/div/table/tbody/tr/td[2]/a/img" time.sleep(2) self.getElem.find_element_wait_and_click_EC("xpath", xpath) time.sleep(2) u'''校验图标 parameters : - rename:资源名称 ''' def check_ico_len(self, rename): self.frameElem.from_frame_to_otherFrame("rigthFrame") time.sleep(3) row = self.acproval.select_resoure_sso(rename) self.acproval.click_refresh_icon(rename) ico_xpath = "/html/body/div[1]/div[7]/div[2]/div[1]/table/tbody/tr[" + str( row * 2) + "]/td/div/table/tbody/tr/td[2]" time.sleep(2) selem = self.getElem.find_element_with_wait_EC("xpath", ico_xpath) selems = selem.find_elements_by_tag_name("a") lengh = len(selems) if lengh > 1: self.log.log_detail(u"双人授权已同意申请,可以进行单点登录", True) else: self.log.log_detail(u"双人授权已拒绝申请,不可以进行单点登录", True) u'''选择授权人 parameters : - authorizer:授权人名称 ''' def select_authorizer(self, authorizer): self.frameElem.switch_to_artIframe() author = self.cnEn.is_float(authorizer) selem = self.getElem.find_element_with_wait_EC("id", "fortApproverId") self.selectElem.select_element_by_visible_text(selem, author) u'''勾选同终端直接输入口令访问''' def check_same_termina(self): self.frameElem.switch_to_artIframe() self.getElem.find_element_wait_and_click_EC("id", "fortIsRemoteApply") u'''填写授权人密码 Parameters: - passwd:授权人密码 ''' def set_authorizer_pwd(self, passwd): self.frameElem.switch_to_artIframe() pwd = self.cnEn.is_float(passwd) self.getElem.find_element_wait_and_clear("id", "password") self.getElem.find_element_wait_and_sendkeys("id", "password", pwd) u'''调用新浏览器''' def call_other_browsers(self): newbrowser = webdriver.Ie() # newbrowser = webdriver.Chrome() #IE窗口最大化 newbrowser.maximize_window() newbrowser.get("https://172.16.10.155") newbrowser.get( "javascript:document.getElementById('overridelink').click();") return newbrowser u'''远程用户登录 Parameters: - listusers:用户集 ''' def user_remote_approval(self, newbrowser, listusers): users = listusers.split() newbrowser.switch_to_default_content() selem = newbrowser.find_element_by_id("loginMethod") Select(selem).select_by_value(users[0]) newbrowser.find_element_by_id("username").click() newbrowser.find_element_by_id("username").send_keys(users[1]) newbrowser.find_element_by_id("pwd").click() newbrowser.find_element_by_id("pwd").send_keys(users[2]) time.sleep(1) newbrowser.find_element_by_id("do_login").click() u'''菜单选择 Parameters: - newbrowser:新浏览器驱动 - levelText1:1级菜单文本 - levelText2:2级菜单文本 - levelText3:3级菜单文本 ''' def click_menu(self, newbrowser, levelText1, levelText2='no', levelText3='no'): self.remote_break_frame(newbrowser, "topFrame") #点击一级菜单 newbrowser.find_element_by_link_text(levelText1).click() time.sleep(1) #如果有2级菜单,再点击2级菜单 if levelText2 != 'no': newbrowser.find_element_by_link_text(levelText2).click() #如果有3级菜单,根据名称点击3级菜单 if levelText3 != 'no': self.remote_break_frame(newbrowser, "leftFrame") newbrowser.find_element_by_link_text(levelText3).click() u'''判断名称是否存在 Parameters: - namevalue:传入的要被查询名称 - name:表格列的name属性 return:true代表存在,false代表不存在 ''' def namevalue_remote_is_exsit(self, newbrowser, namevalue, name): nameval = self.cnEn.is_float(namevalue) namesex = self.cnEn.is_float(name) isExsit = False text_list = newbrowser.find_elements_by_name(namesex) for fortNameValue in text_list: fortNameValue_text = fortNameValue.text if fortNameValue_text == nameval: isExsit = True break return isExsit u'''查询已存在名称位于第几行 Parameters: - namevalue:传入的要被查询名称 - name:表格列的name属性 return:定位该名称位于第几行 ''' def find_name_remote_by_row(self, newbrowser, namevalue, name): self.remote_break_frame(newbrowser, "mainFrame") nameval = self.cnEn.is_float(namevalue) namesex = self.cnEn.is_float(name) row = 0 if self.namevalue_remote_is_exsit(newbrowser, nameval, namesex): text_list = newbrowser.find_elements_by_name(namesex) for fortNameValue in text_list: row = row + 1 fortNameValue_text = fortNameValue.text if fortNameValue_text == nameval: break return row u'''通过流程号点击要审批的信息 Parameters: - number:流程号 ''' def click_remote_approval_by_number(self, newbrowser, number): row = self.find_name_remote_by_row(newbrowser, number, "fortProcessInstanceId") xpath = "/html/body/form/div/div[7]/div[2]/div/table/tbody/tr[" + str( row) + "]/td[8]/input[1]" newbrowser.find_element_by_xpath(xpath).click() u'''流程控制是否同意审批 Parameters: - status:1代表同意审批,2代表拒绝审批 ''' def process_remote_is_agree_approval(self, newbrowser, status): statu = self.cnEn.is_float(status) self.remote_break_frame(newbrowser, "mainFrame") if statu == '1': newbrowser.find_element_by_id("yes").click() elif statu == '2': newbrowser.find_element_by_id("no").click() u'''填写流程控制中审批申请单的描述 Parameters: - description:描述内容 ''' def set_process_remote_description(self, newbrowser, description): descri = self.cnEn.is_float(description) self.remote_break_frame(newbrowser, "mainFrame") newbrowser.find_element_by_id("fortApprovalOpinions").clear() newbrowser.find_element_by_id("fortApprovalOpinions").send_keys(descri) u'''点击提交按钮''' def click_remote_submit(self, newbrowser): self.remote_break_frame(newbrowser, "mainFrame") newbrowser.find_element_by_id("save_process_approval").click() u'''点击确定按钮''' def click_remote_msg_button(self, newbrowser): newbrowser.switch_to_default_content() OKBTN = "//div[@id='aui_buttons']/button[1]" newbrowser.find_element_by_xpath(OKBTN).click() u'''点击返回按钮''' def remote_back(self, newbrowser): self.remote_break_frame(newbrowser, "mainFrame") newbrowser.find_element_by_id("history_skip").click() u'''跳转frame Parameters: - frameName:要跳转到的frame的名字 ''' def remote_break_frame(self, newbrowser, frameName): newbrowser.switch_to_default_content() newbrowser.switch_to_frame("content1") newbrowser.switch_to_frame(frameName) u'''点击退出''' def remote_quit(self, newbrowser): self.remote_break_frame(newbrowser, "topFrame") time.sleep(1) newbrowser.find_element_by_id("logout").click() u'''申请人发送双人审批申请 Parameters: - data:excel中的一行数据 ''' def send_double_license_applicant(self, data): self.acproval.select_resoure_account(data[1], data[2]) self.click_double_license_icon(data[1]) self.select_authorizer(data[3]) if data[4] != 'no': self.check_same_termina() self.set_authorizer_pwd(data[4]) self.acproval.set_operation_description(data[5]) self.acproval.click_sure_button() self.driver.implicitly_wait(10) self.log.log_detail(data[0], True) u'''审批人通过当前浏览器流程控制进行审批 Parameters: - number:流程号 ''' def approver_by_process_approval(self, expData, number): xpathMsg = ".//*[@id='body1']/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div" #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(expData)): data = expData[dataRow] try: #如果不是第1行,读取数据 if dataRow != 0: self.acproval.user_login(data[2]) self.frameElem.from_frame_to_otherFrame("topFrame") self.cmf.select_menu(u"流程控制", u"流程任务") self.acproval.click_approval_by_number(number) if data[1] != 'no': self.frameElem.switch_to_content() self.cmf.test_win_check_point("xpath", xpathMsg, data, flag) else: self.acproval.process_is_agree_approval(data[3]) self.acproval.set_process_apply_description(data[4]) self.acproval.click_submit() self.cmf.click_login_msg_button() self.acproval.back_quit_common() except Exception as e: print("expired_approvel fail:" + str(e)) u'''审批人通过新开启的浏览器流程控制进行审批 Parameters: - number:流程号 ''' def approver_remote_approval(self, expData, number): for dataRow in range(len(expData)): data = expData[dataRow] try: #如果不是第1行,读取数据 if dataRow != 0: newbrowser = self.call_other_browsers() self.user_remote_approval(newbrowser, data[1]) self.click_menu(newbrowser, u"流程控制", u"流程任务") self.click_remote_approval_by_number(newbrowser, number) self.process_remote_is_agree_approval(newbrowser, data[2]) self.set_process_remote_description(newbrowser, data[3]) self.click_remote_submit(newbrowser) self.click_remote_msg_button(newbrowser) self.remote_back(newbrowser) self.driver.implicitly_wait(5) self.remote_quit(newbrowser) newbrowser.quit() except Exception as e: print("expired_approvel fail:" + str(e))
class CommandRule(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cmf = commonFun(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.ssoElem = SsoPage(self.driver) u'''左边框点击规则 Parameters: - statu:左边框点击,0代表点击命令规则,1代表点击时间规则,2代表点击地址规则,3代表点击资源时间规则 ''' def click_left_rule(self, statu): self.frameElem.from_frame_to_otherFrame("leftFrame") if statu == 0: #点击命令规则 self.getElem.find_element_wait_and_click_EC("id", "url0") elif statu == 1: #点击时间规则 self.getElem.find_element_wait_and_click_EC("id", "url1") elif statu == 2: #点击地址规则 self.getElem.find_element_wait_and_click_EC("id", "url2") elif statu == 3: #点击资源时间规则 self.getElem.find_element_wait_and_click_EC("id", "url3") u'''点击添加''' def click_add_button(self): time.sleep(1) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("classname", "btn_tj") u'''点击删除''' def click_del_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "delete_rule_command") u'''点击复选框全选''' def check_all(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "checkbox") u'''点击部署''' def click_deploy_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "updateAllState") u'''选择命令类型 Parameters: - value:select选项中的value属性值,0代表黑名单,2代表审批命令 ''' def select_command_type(self, value): valu = self.cnEn.is_float(value) self.frameElem.from_frame_to_otherFrame("rigthFrame") selem = self.getElem.find_element_with_wait_EC("id", "fortRuleCommandTypeList") self.selectElem.select_element_by_value(selem, valu) u'''填写命令 Parameters: - command:命令内容 ''' def set_command(self, command): comm = self.cnEn.is_float(command) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "new_command") self.getElem.find_element_wait_and_sendkeys("id", "new_command", comm) u'''清空已添加命令''' def clear_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") inputelems = self.driver.find_elements_by_name("passwordTable") for inputelem in inputelems: inputelem.click() u'''点击添加命令按钮''' def click_add_command_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "add_command") u'''测试命令 Parameters: - command:命令内容 ''' def set_test_command(self, command): comm = self.cnEn.is_float(command) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "test") self.getElem.find_element_wait_and_sendkeys("id", "test", comm) u'''点击测试命令按钮''' def click_test_command_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "test_command") u'''点击添加用户按钮''' def click_add_users_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn_tjyh") u'''点击添加用户组按钮''' def click_add_usergroup_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn_tjyhz") u'''点击添加资源按钮''' def click_add_resource_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn_tjzyzy") u'''点击添加资源组按钮''' def click_add_regroup_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn01_tjyhz") u'''点击添加资源账号按钮''' def click_add_reaccount_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn_tjzy") u'''点击删除资源按钮''' def click_del_resource_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "del_resource") u'''点击删除资源账号按钮''' def click_del_reaccount_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "del_account") u'''点击保存按钮''' def click_save_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "save_rule_command") u'''点击返回按钮''' def click_back_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "history_skip") u'''点击审批人按钮''' def click_approver_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn_tjspr") u'''点击用户检索按钮''' def click_check_user(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "quick_user") u'''点击资源检索按钮''' def click_check_resource(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "quick_query") u'''勾选全部用户''' def check_all_user(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.click_check_user() self.getElem.find_element_wait_and_click_EC("id", "user_check_all") self.check_sure_button() u'''勾选全部资源''' def check_all_resource(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.click_check_resource() self.getElem.find_element_wait_and_click_EC("id", "resource_check_all") self.check_sure_button() u'''点击确定按钮''' def check_sure_button(self): self.frameElem.switch_to_content() self.getElem.find_element_wait_and_click_EC("id", "okButton") u'''填写插入行数 Parameters: - row:行数 ''' def set_row_command(self, row): rows = self.cnEn.is_float(row) self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear("id", "rows") self.getElem.find_element_wait_and_sendkeys("id", "rows", rows) u'''点击插入行数的返回按钮''' def click_cancel_button(self): self.frameElem.switch_to_content() self.getElem.find_element_wait_and_click_EC("id", "cancelButton") u'''勾选用户 parameter: - listuser:用户集合 ''' def check_user_command(self, listuser): self.frameElem.from_frame_to_otherFrame("artIframe") # 获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "user_table") self.check_common(tableelem, listuser) u'''勾选资源 parameter: - listresource:资源集合 ''' def check_resource_command(self, listresource): self.frameElem.from_frame_to_otherFrame("artIframe") # 获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "resourceTable") self.check_common(tableelem, listresource) u'''勾选用户或者资源公共方法 parameter: - tableelem:表属性对象 - lists:用户集合 ''' def check_common(self, tableelem, lists): # 获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") # 位于第几行 line = 0 # 循环所有tr for trelem in trelems: line += 1 # 找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") # 获取td[2]的文本 tdtext = tds[1].text for user in lists.split(): if tdtext == user: xpath = "/html/body/div[3]/div[2]/table/tbody/tr[" + str(line) + "]/td[1]/li/input" self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''勾选用户组 parameter: - listuser:用户集合 ''' def check_usergroup_command(self, usergroups): self.check_group_common("userGroup_1_switch", "userGroup", usergroups, "userGroup_") u'''勾选资源组 parameter: - listuser:用户集合 ''' def check_regroup_command(self, regroups): self.check_group_common("resourceGroup_1_switch", "resourceGroup", regroups, "resourceGroup_") u'''勾选组的公共方法 parameter: - extendid:闭合按钮的id属性 - ulid:ul的id属性 - groups:组集合 - idfirst:span标签的id属性数字前面的字符 ''' def check_group_common(self, extendid, ulid, groups, idfirst): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", extendid) # 获取ul对象 ulelem = self.getElem.find_element_with_wait_EC("id", ulid) # 获取ul对象下的所有a aelems = ulelem.find_elements_by_tag_name("a") for elem in aelems: #获取tr的title属性 atext = elem.get_attribute("title") for usergrop in groups.split(): if atext == usergrop: #获取tr的id属性 aid = elem.get_attribute("id") spanid = idfirst + filter(str.isdigit, aid) + "_check" self.getElem.find_element_wait_and_click_EC("id", spanid) break u'''点击操作的公共方法 parameter: - value:序号 - statu:代表点击的操作,1代表勾选复选框;2代表状态开关;3代表上移;4代表下移;5代表插入;6代表编辑 ''' def click_action_public_command(self, value, status): self.frameElem.from_frame_to_otherFrame("rigthFrame") valu = self.cnEn.is_float(value) statu = self.cnEn.is_float(status) # 获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "content_table") # 获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") # 位于第几行 line = 0 # 循环所有tr for trelem in trelems: line += 1 # 找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") # 获取td[2]的文本 tdtext = tds[1].text if tdtext == valu: #勾选复选框 if statu == '1': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[1]/input[1]" #状态开关 elif statu == '2': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[8]/input[1]" #上移 elif statu == '3': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[1]" #下移 elif statu == '4': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[2]" #插入 elif statu == '5': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[3]" #编辑 elif statu == '6': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[4]" self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''点击消息提示''' def click_message_prompt(self): self.frameElem.from_frame_to_otherFrame('topFrame') self.getElem.find_element_wait_and_click_EC("id", "link_tc") u'''点击消息详情''' def click_message_detail(self): self.frameElem.from_frame_to_otherFrame('topFrame') time.sleep(3) self.click_message_prompt() time.sleep(2) ulselem = self.getElem.find_element_with_wait_EC("id", "digest") # 找到ul下所有a对象 aselems = ulselem.find_elements_by_tag_name("a") aselems[0].click() u'''选择审批用户 parameter: - username:审批用户名称 ''' def select_approval_user(self, username): self.frameElem.from_frame_to_otherFrame('artIframe') name = self.cnEn.is_float(username) elem = self.getElem.find_element_with_wait_EC("id", "fortApproverId") self.selectElem.select_element_by_visible_text(elem, name) u'''填写口令 Parameters: - pwd:口令 ''' def set_passwd(self, pwd): passwd = self.cnEn.is_float(pwd) self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear("id", "password") self.getElem.find_element_wait_and_sendkeys("id", "password", passwd) u'''填写备注信息 Parameters: - descrip:备注信息 ''' def set_descrip(self, descrip): description = self.cnEn.is_float(descrip) self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear("id", "fortDescription") self.getElem.find_element_wait_and_sendkeys("id", "fortDescription", description) u'''通过消息进行命令审批 Parameters: - user:用户名称 - pwd:密码 - descrip:备注信息 ''' def command_by_message_approval(self, user, pwd, descrip): self.frameElem.switch_to_content() time.sleep(5) self.click_message_detail() time.sleep(2) self.select_approval_user(user) time.sleep(1) self.set_passwd(pwd) self.set_descrip(descrip) self.check_sure_button() time.sleep(2) u'''通过流程控制进行命令审批 Parameters: - user:用户名称 - pwd:密码 - descrip:备注信息 ''' def command_by_flow_approval(self, user, pwd, descrip): #获取流程号 number = self.acproval.get_new_process_number() self.cmf.select_menu(u"流程控制", u"流程任务") self.acproval.click_approval_by_number(number) self.select_approval_user(user) self.set_passwd(pwd) self.set_descrip(descrip) self.check_sure_button() u'''根据浏览器类型进行单点登录''' def choice_browser_open(self,iconType,username,pwd,cmdList): fileList = fileRead().get_ip_address() browserType = fileList[1].strip('\n') if browserType == '1': time.sleep(5) self.ssoElem.execute_chrome_key() elif browserType != '0' or browserType != '1': self.ssoElem.opt_cmd("\\testIsomp\\webElement\\sso\\sso_firefox.exe","", "","","") time.sleep(3) self.ssoElem.opt_cmd("\\testIsomp\\webElement\\rule\\sso_command_open.exe",iconType, username,pwd,cmdList) u'''根据浏览器类型关闭单点登录''' def choice_browser_close(self,iconType): self.ssoElem.opt_cmd("\\testIsomp\\webElement\\rule\\sso_command_close.exe",iconType,"","","") u'''命令审批单点登录''' def sso_command(self, data): time.sleep(2) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.ssoElem.select_account(data[2],data[3]) self.click_sso_icon(data[2]) if data[4] != "": self.ssoElem.select_protocol(data[4]) time.sleep(5) SendKeys.SendKeys(str(data[5])) SendKeys.SendKeys('\n', with_newlines=True) time.sleep(2) u'''点击单点登录图标 parameters : rename : 资源名称 ''' def click_sso_icon(self, rename): self.frameElem.from_frame_to_otherFrame("rigthFrame") rname = self.cnEn.is_float(rename) row = self.acproval.select_resoure_sso(rname) xpath = "/html/body/div[1]/div[7]/div[2]/div/table/tbody/tr[" + str( row * 2) + "]/td/div/table/tbody/tr/td[2]/a/img" time.sleep(2) self.getElem.find_element_wait_and_click_EC("xpath", xpath) time.sleep(2)
class CommandRule(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.cmf = commonFun(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.ssoElem = SsoPage(self.driver) u'''左边框点击规则 Parameters: - statu:左边框点击,0代表点击命令规则,1代表点击时间规则,2代表点击地址规则,3代表点击资源时间规则 ''' def click_left_rule(self, statu): self.frameElem.from_frame_to_otherFrame("leftFrame") if statu == 0: #点击命令规则 self.getElem.find_element_wait_and_click_EC("id", "url0") elif statu == 1: #点击时间规则 self.getElem.find_element_wait_and_click_EC("id", "url1") elif statu == 2: #点击地址规则 self.getElem.find_element_wait_and_click_EC("id", "url2") elif statu == 3: #点击资源时间规则 self.getElem.find_element_wait_and_click_EC("id", "url3") u'''点击添加''' def click_add_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("classname", "btn_tj") u'''点击删除''' def click_del_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "delete_rule_command") u'''点击复选框全选''' def check_all(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "checkbox") u'''点击部署''' def click_deploy_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "updateAllState") u'''选择命令类型 Parameters: - value:select选项中的value属性值,0代表黑名单,2代表审批命令 ''' def select_command_type(self, value): valu = self.cnEn.is_float(value) self.frameElem.from_frame_to_otherFrame("rigthFrame") selem = self.getElem.find_element_with_wait_EC("id", "fortRuleCommandTypeList") self.selectElem.select_element_by_value(selem, valu) u'''填写命令 Parameters: - command:命令内容 ''' def set_command(self, command): comm = self.cnEn.is_float(command) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "new_command") self.getElem.find_element_wait_and_sendkeys("id", "new_command", comm) u'''清空已添加命令''' def clear_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") inputelems = self.driver.find_elements_by_name("passwordTable") for inputelem in inputelems: inputelem.click() u'''点击添加命令按钮''' def click_add_command_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "add_command") u'''测试命令 Parameters: - command:命令内容 ''' def set_test_command(self, command): comm = self.cnEn.is_float(command) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "test") self.getElem.find_element_wait_and_sendkeys("id", "test", comm) u'''点击测试命令按钮''' def click_test_command_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "test_command") u'''点击添加用户按钮''' def click_add_users_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn_tjyh") u'''点击添加用户组按钮''' def click_add_usergroup_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn_tjyhz") u'''点击添加资源按钮''' def click_add_resource_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn_tjzyzy") u'''点击添加资源组按钮''' def click_add_regroup_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn01_tjyhz") u'''点击添加资源账号按钮''' def click_add_reaccount_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn_tjzy") u'''点击删除资源按钮''' def click_del_resource_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "del_resource") u'''点击删除资源账号按钮''' def click_del_reaccount_button(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "del_account") u'''点击保存按钮''' def click_save_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "save_rule_command") u'''点击返回按钮''' def click_back_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "history_skip") u'''点击审批人按钮''' def click_approver_command(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "btn_tjspr") u'''点击用户检索按钮''' def click_check_user(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "quick_user") u'''点击资源检索按钮''' def click_check_resource(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", "quick_query") u'''勾选全部用户''' def check_all_user(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.click_check_user() self.getElem.find_element_wait_and_click_EC("id", "user_check_all") self.check_sure_button() u'''勾选全部资源''' def check_all_resource(self): self.frameElem.from_frame_to_otherFrame("artIframe") self.click_check_resource() self.getElem.find_element_wait_and_click_EC("id", "resource_check_all") self.check_sure_button() u'''点击确定按钮''' def check_sure_button(self): self.frameElem.switch_to_content() self.getElem.find_element_wait_and_click_EC("id", "okButton") u'''填写插入行数 Parameters: - row:行数 ''' def set_row_command(self, row): rows = self.cnEn.is_float(row) self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear("id", "rows") self.getElem.find_element_wait_and_sendkeys("id", "rows", rows) u'''点击插入行数的返回按钮''' def click_cancel_button(self): self.frameElem.switch_to_content() self.getElem.find_element_wait_and_click_EC("id", "cancelButton") u'''勾选用户 parameter: - listuser:用户集合 ''' def check_user_command(self, listuser): self.frameElem.from_frame_to_otherFrame("artIframe") # 获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "user_table") self.check_common(tableelem, listuser) u'''勾选资源 parameter: - listresource:资源集合 ''' def check_resource_command(self, listresource): self.frameElem.from_frame_to_otherFrame("artIframe") # 获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "resourceTable") self.check_common(tableelem, listresource) u'''勾选用户或者资源公共方法 parameter: - tableelem:表属性对象 - lists:用户集合 ''' def check_common(self, tableelem, lists): # 获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") # 位于第几行 line = 0 # 循环所有tr for trelem in trelems: line += 1 # 找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") # 获取td[2]的文本 tdtext = tds[1].text for user in lists.split(): if tdtext == user: xpath = "/html/body/div[3]/div[2]/table/tbody/tr[" + str(line) + "]/td[1]/li/input" self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''勾选用户组 parameter: - listuser:用户集合 ''' def check_usergroup_command(self, usergroups): self.check_group_common("userGroup_1_switch", "userGroup", usergroups, "userGroup_") u'''勾选资源组 parameter: - listuser:用户集合 ''' def check_regroup_command(self, regroups): self.check_group_common("resourceGroup_1_switch", "resourceGroup", regroups, "resourceGroup_") u'''勾选组的公共方法 parameter: - extendid:闭合按钮的id属性 - ulid:ul的id属性 - groups:组集合 - idfirst:span标签的id属性数字前面的字符 ''' def check_group_common(self, extendid, ulid, groups, idfirst): self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_click_EC("id", extendid) # 获取ul对象 ulelem = self.getElem.find_element_with_wait_EC("id", ulid) # 获取ul对象下的所有a aelems = ulelem.find_elements_by_tag_name("a") for elem in aelems: #获取tr的title属性 atext = elem.get_attribute("title") for usergrop in groups.split(): if atext == usergrop: #获取tr的id属性 aid = elem.get_attribute("id") spanid = idfirst + filter(str.isdigit, aid) + "_check" self.getElem.find_element_wait_and_click_EC("id", spanid) break u'''点击操作的公共方法 parameter: - value:序号 - statu:代表点击的操作,1代表勾选复选框;2代表状态开关;3代表上移;4代表下移;5代表插入;6代表编辑 ''' def click_action_public_command(self, value, status): self.frameElem.from_frame_to_otherFrame("rigthFrame") valu = self.cnEn.is_float(value) statu = self.cnEn.is_float(status) # 获取table对象 tableelem = self.getElem.find_element_with_wait_EC("id", "content_table") # 获取table对象下的所有tr trelems = tableelem.find_elements_by_tag_name("tr") # 位于第几行 line = 0 # 循环所有tr for trelem in trelems: line += 1 # 找到tr下所有td对象 tds = trelem.find_elements_by_tag_name("td") # 获取td[2]的文本 tdtext = tds[1].text if tdtext == valu: #勾选复选框 if statu == '1': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[1]/input[1]" #状态开关 elif statu == '2': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[8]/input[1]" #上移 elif statu == '3': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[1]" #下移 elif statu == '4': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[2]" #插入 elif statu == '5': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[3]" #编辑 elif statu == '6': xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(line) + "]/td[9]/a[4]" self.getElem.find_element_wait_and_click_EC("xpath", xpath) break u'''点击消息提示''' def click_message_prompt(self): self.frameElem.from_frame_to_otherFrame('topFrame') self.getElem.find_element_wait_and_click_EC("id", "link_tc") u'''点击消息详情''' def click_message_detail(self): self.frameElem.from_frame_to_otherFrame('topFrame') time.sleep(3) self.click_message_prompt() time.sleep(2) ulselem = self.getElem.find_element_with_wait_EC("id", "digest") # 找到ul下所有a对象 aselems = ulselem.find_elements_by_tag_name("a") aselems[0].click() u'''选择审批用户 parameter: - username:审批用户名称 ''' def select_approval_user(self, username): self.frameElem.from_frame_to_otherFrame('artIframe') name = self.cnEn.is_float(username) elem = self.getElem.find_element_with_wait_EC("id", "fortApproverId") self.selectElem.select_element_by_visible_text(elem, name) u'''填写口令 Parameters: - pwd:口令 ''' def set_passwd(self, pwd): passwd = self.cnEn.is_float(pwd) self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear("id", "password") self.getElem.find_element_wait_and_sendkeys("id", "password", passwd) u'''填写备注信息 Parameters: - descrip:备注信息 ''' def set_descrip(self, descrip): description = self.cnEn.is_float(descrip) self.frameElem.from_frame_to_otherFrame("artIframe") self.getElem.find_element_wait_and_clear("id", "fortDescription") self.getElem.find_element_wait_and_sendkeys("id", "fortDescription", description) u'''通过消息进行命令审批 Parameters: - user:用户名称 - pwd:密码 - descrip:备注信息 ''' def command_by_message_approval(self, user, pwd, descrip): self.frameElem.switch_to_content() time.sleep(5) self.click_message_detail() time.sleep(2) self.select_approval_user(user) time.sleep(1) self.set_passwd(pwd) self.set_descrip(descrip) self.check_sure_button() time.sleep(2) u'''通过流程控制进行命令审批 Parameters: - user:用户名称 - pwd:密码 - descrip:备注信息 ''' def command_by_flow_approval(self, user, pwd, descrip): #获取流程号 number = self.acproval.get_new_process_number() self.cmf.select_menu(u"流程控制", u"流程任务") self.acproval.click_approval_by_number(number) self.select_approval_user(user) self.set_passwd(pwd) self.set_descrip(descrip) self.check_sure_button() u'''根据浏览器类型进行单点登录''' def choice_browser_open(self,iconType,username,pwd,cmdList): fileList = fileRead().get_ip_address() browserType = fileList[1].strip('\n') if browserType == '1': time.sleep(5) self.ssoElem.execute_chrome_key() elif browserType != '0' or browserType != '1': self.ssoElem.opt_cmd("\\testIsomp\\webElement\\sso\\sso_firefox.exe","", "","","") time.sleep(3) self.ssoElem.opt_cmd("\\testIsomp\\webElement\\rule\\sso_command_open.exe",iconType, username,pwd,cmdList) u'''根据浏览器类型关闭单点登录''' def choice_browser_close(self,iconType): self.ssoElem.opt_cmd("\\testIsomp\\webElement\\rule\\sso_command_close.exe",iconType,"","","") u'''命令审批单点登录''' def sso_command(self, data): time.sleep(2) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.ssoElem.select_account(data[2],data[3]) self.click_sso_icon(data[2]) if data[4] != "": self.ssoElem.select_protocol(data[4]) time.sleep(5) SendKeys.SendKeys(str(data[5])) SendKeys.SendKeys('\n', with_newlines=True) time.sleep(2) u'''点击单点登录图标 parameters : rename : 资源名称 ''' def click_sso_icon(self, rename): self.frameElem.from_frame_to_otherFrame("rigthFrame") rname = self.cnEn.is_float(rename) row = self.acproval.select_resoure_sso(rname) xpath = "/html/body/div[1]/div[7]/div[2]/div/table/tbody/tr[" + str( row * 2) + "]/td/div/table/tbody/tr/td[2]/a/img" time.sleep(2) self.getElem.find_element_wait_and_click_EC("xpath", xpath) time.sleep(2)
class 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 TimeRule(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.tableElem = tableElement(driver) self.cmf = commonFun(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.user = UserPage(driver) u'''点击批量删除''' def click_bulkdel_time(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "delete_rule_time") u'''填写时间规则名称 Parameters: - rulename:时间规则名称 ''' def set_rulename(self, rulename): name = self.cnEn.is_float(rulename) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "fortRuleTimeName") self.getElem.find_element_wait_and_sendkeys("id", "fortRuleTimeName", name) u'''选择部门 Parameters: - deptname:部门名称 ''' def select_depart(self, deptname): name = self.cnEn.is_float(deptname) self.select_depart_right_common("department_name", "tree_1_switch", name) time.sleep(2) u'''启动日期 Parameters: - type:t代表今天,c代表clear,q代表确定,默认选择今天 - starttime:启动日期 ''' def start_date(self, types, starttime=None): self.frameElem.from_frame_to_otherFrame("rigthFrame") # 时间控件的fram的xpath # fxpath = "//iframe[@hidefocus='true']" fxpath = "/html/body/div/iframe" # 日期控件table的xpath路径 txpath = "/html/body/div/div[3]/table" status = self.cnEn.is_float('0') type = self.cnEn.is_float(types) if starttime != None: # 转成datetime对象 date = datetime(*xldate_as_tuple(starttime, 0)) start = date.strftime('%Y-%m-%d %H:%M:%S') self.option_time_rule("fortStartTime", fxpath, status, type, txpath, start) else: self.option_time_rule("fortStartTime", fxpath, status, type, txpath) u'''结束日期 Parameters: - type:t代表今天,c代表clear,q代表确定,默认选择今天 - endtime:结束日期设定的日期,格式为2016-9-7 11:42:42 ''' def date_of_termination(self, types, endtime): self.frameElem.from_frame_to_otherFrame("rigthFrame") # 时间控件的fram的xpath fxpath = "//iframe[@hidefocus='true']" # 日期控件table的xpath路径 txpath = "/html/body/div/div[3]/table" status = self.cnEn.is_float('0') type = self.cnEn.is_float(types) # 转成datetime对象 date = datetime(*xldate_as_tuple(endtime, 0)) end = date.strftime('%Y-%m-%d %H:%M:%S') self.option_time_rule("fortEndTime", fxpath, status, type, txpath, end) u'''设置状态类型 Parameters: - status: 状态类型0代表禁止使用,1代表允许使用 ''' def set_status_type(self, status): self.frameElem.from_frame_to_otherFrame("rigthFrame") statu = self.cnEn.is_float(status) selem = self.getElem.find_element_with_wait_EC("id", "fortAccessType") self.selectElem.select_element_by_value(selem, statu) u'''设置时间 Parameters: - method: 设置方式 option的value值 - weeks: 星期(可多选)option的value值 - hours: 小时(可多选) ''' def set_time(self, methods, weeks, hours='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") #设置时间方式 method = self.cnEn.is_float(methods) selem = self.getElem.find_element_with_wait_EC("id", "method") self.selectElem.select_element_by_value(selem, method) #设置日期 week = weeks.split() if methods == "weeks": for data in week: welem = self.getElem.find_element_with_wait_EC("id", "fortWeeks") self.selectElem.select_element_by_value(welem, data) elif methods == "days": for data in week: welem = self.getElem.find_element_with_wait_EC("id", "fortDays") self.selectElem.select_element_by_value(welem, data) if hours != 'no': #设置小时 hour = hours.split() for hr in hour: helem = self.getElem.find_element_with_wait_EC("id", "fortHours") self.selectElem.select_element_by_value(helem, hr) u'''取消时间 Parameters: - method: 设置方式 option的value值 - weeks: 星期(可多选)option的value值 - hours: 小时(可多选) ''' def deselect_time(self, methods, weeks, hours='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") #设置日期 week = weeks.split() if methods == "weeks": for data in week: welem = self.getElem.find_element_with_wait_EC("id", "fortWeeks") self.selectElem.deselect_element_by_value(welem, data) elif methods == "days": for data in week: welem = self.getElem.find_element_with_wait_EC("id", "fortDays") self.selectElem.deselect_element_by_value(welem, data) if hours != 'no': #设置小时 hour = hours.split() for hr in hour: helem = self.getElem.find_element_with_wait_EC("id", "fortHours") self.selectElem.deselect_element_by_value(helem, hr) u'''填写描述信息 Parameters: - descrip:描述信息 ''' def set_descrip(self, descrip): self.frameElem.from_frame_to_otherFrame("rigthFrame") description = self.cnEn.is_float(descrip) self.getElem.find_element_wait_and_clear("id", "fortDescription") self.getElem.find_element_wait_and_sendkeys("id", "fortDescription", description) u'''点击保存按钮''' def click_save_time(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "save_rule_time") u'''填写检索名称 Parameters: - timename:名称 ''' def set_search_timename(self, timename): self.frameElem.from_frame_to_otherFrame("rigthFrame") name = self.cnEn.is_float(timename) self.getElem.find_element_wait_and_clear("id", "fortRuleTimeName") self.getElem.find_element_wait_and_sendkeys("id", "fortRuleTimeName", name) u'''点击检索按钮''' def click_search_time(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "retFortRuleTimeName") u'''点击重置''' def click_reset_time(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "resetting") u'''点击编辑按钮 Parameters: - timename:时间规则名称 ''' def click_edit_time(self, timename): try: self.frameElem.from_frame_to_otherFrame("rigthFrame") row = self.acproval.find_name_by_row(timename, "fortRuleTimeName") update_xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(row) + "]/td[6]/input[1]" self.getElem.find_element_wait_and_click("xpath", update_xpath) except Exception: print("Click the Edit button to fail") u'''点击删除按钮 Parameters: - timename:时间规则名称 ''' def click_del_time(self, timename): try: self.frameElem.from_frame_to_otherFrame("rigthFrame") row = self.acproval.find_name_by_row(timename, "fortRuleTimeName") del_xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(row) + "]/td[6]/input[2]" self.getElem.find_element_wait_and_click("xpath", del_xpath) except Exception: print("Click the Del button to fail") u'''选择部门公共方法 parameter: - idname:填写框id - swithid:部门展开按钮id - deptname:部门名称 ''' def select_depart_right_common(self, idname, swithid, deptname): try: self.frameElem.from_frame_to_otherFrame("rigthFrame") self.driver.implicitly_wait(10) self.getElem.find_element_wait_and_click_EC('id', idname) self.driver.implicitly_wait(10) self.getElem.find_element_wait_and_click_EC('id', swithid) self.driver.implicitly_wait(10) #获取所有a标签的对象 elems = self.driver.find_elements_by_tag_name("a") for elem in elems: elemtext = elem.get_attribute("title") elemid = elem.get_attribute("id") if deptname == elemtext: self.getElem.find_element_wait_and_click("id", elemid) break except Exception as e: print "Department select error:" + str(e) u'''操作时间控件 Parameters: - wdateId:日期控件input控件的ID值 - fxpath:日期控件frame的xpath路径 - status: 日期控件是否有时分秒 - txpath:日期控件table的xpath路径 - time:设定的日期,格式为2016-9-7 11:42:42 - type:t代表今天,c代表clear,q代表确定,默认选择今天 ''' def option_time_rule(self,wdateId,fxpath,status='0',type='t',txpath = None,dtime = None): self.getElem.find_element_wait_and_click("id",wdateId) frame = self.driver.find_element_by_xpath(fxpath) self.driver.switch_to_frame(frame) if type == 't': self.getElem.find_element_wait_and_click("id","dpTodayInput") elif type == 'c': self.getElem.find_element_wait_and_click("id","dpClearInput") elif type == 'q': if dtime is not None: list = dtime.split() ymdList = list[0].split("-") hmsList = list[1].split(":") #年 tYear = ymdList[0] #月 tMon = ymdList[1] #日 tDay = ymdList[2] #时 tHour = hmsList[0] #分 tMin = hmsList[1] #秒 tSen = hmsList[2] dTitle = self.getElem.find_element_with_wait("id","dpTitle").find_elements_by_tag_name("input") #设定月 dTitle[0].clear() dTitle[0].send_keys(tMon) #设定年 dTitle[1].clear() dTitle[1].send_keys(tYear) self.frameElem.from_frame_to_otherFrame("rigthFrame") if wdateId == "fortStartTime": self.getElem.find_element_wait_and_click_EC("id", "fortStartTime") elif wdateId == "fortEndTime": self.getElem.find_element_wait_and_click_EC("id", "fortEndTime") self.driver.switch_to_frame(frame) if txpath is not None: iStatus = False for itr in range(7): if itr != 0: for itd in range(7): ct = self.tableElem.get_table_cell_text(txpath,itr,itd)[0] #排除第一行大于7的 if itr == 1 and int(ct) > 7: continue #排除倒数第二行小于15的 if itr == 5 and int(ct) < 15: continue #排除最后一行小于15的 if itr == 6 and int(ct) < 15: continue #如果跟给定的日期一致,点击日期 if int(ct) == int(tDay): self.tableElem.get_table_cell_text(txpath,itr,itd)[1].click() iStatus = True break #找到日期后跳出循环 if iStatus: break #日期控件是否有时分秒 if status == '1': dTime = self.getElem.find_element_with_wait("id","dpTime").find_elements_by_tag_name("input") #设定小时 dTime[0].clear() dTime[0].send_keys(tHour) #设定分钟 dTime[2].clear() dTime[2].send_keys(tMin) #设定秒 dTime[4].clear() dTime[4].send_keys(tSen) self.getElem.find_element_wait_and_click("id","dpOkInput") u'''给用户添加时间规则 Parameters: - username:要编辑的用户名称 - timerule:时间规则test值 ''' def edit_user_time_rule(self, username, timerule): self.frameElem.from_frame_to_otherFrame("mainFrame") name = self.cnEn.is_float(username) self.user.operate_edit(name) self.user.click_advanced_option() self.select_time_rule(timerule) self.user.save_button() self.cmf.click_login_msg_button() self.user.click_back_button() u'''选择时间规则 Parameters: - timerule:时间规则test值 ''' def select_time_rule(self, timerule): self.frameElem.from_frame_to_otherFrame("mainFrame") timer = self.cnEn.is_float(timerule) select_elem = self.getElem.find_element_with_wait_EC('id',"fortRuleTimeId") self.selectElem.select_element_by_visible_text(select_elem, timer)
class testDobapproval(object): def __init__(self, driver): self.driver = driver self.log = log() self.data = dataFileName() self.cmf = commonFun(driver) self.double = Dobapproval(driver) self.comsuit = CommonSuiteData(self.driver) self.loginElem = loginPage(self.driver) self.authElem = AuthorizationPage(self.driver) self.acproval = Accapproval(driver) self.flow = Flowcontrol(self.driver) self.frameElem = frameElement(self.driver) u'''获取测试数据 Parameters: - sheetname:sheet名称 return:表格数据 ''' def get_double_data(self, sheetname): dataFile = dataFileName() dobPath = dataFile.get_double_license_test_data_url() dobData = dataFile.get_data(dobPath, sheetname) return dobData u'''添加双人授权''' def add_double_license_001(self): #日志开始记录 self.log.log_start("add_double_license") #获取双人授权的数据 dobData = self.get_double_data("add_double_license") for dataRow in range(len(dobData)): data = dobData[dataRow] try: #如果不是第1行,读取数据 if dataRow != 0: self.double.click_double_license_button(data[1]) self.authElem.click_all_approver() self.authElem.click_all_candidate() self.authElem.click_start_association() self.authElem.click_create_relate() self.cmf.click_login_msg_button() #点击返回 self.authElem.click_child_page_back_button() self.log.log_detail(u"添加双人授权成功", True) except Exception as e: print("add_double_license fail: ") + str(e) self.log.log_end("add_double_license") u'''双人审批同终端审批''' def same_termina_approvel_002(self): self.cmf.select_role_by_text(u"运维操作员") #日志开始记录 self.log.log_start("same_termina_approvel") #获取双人审批申请的数据 dobData = self.get_double_data("double_license_sso") for dataRow in range(len(dobData)): data = dobData[dataRow] try: #如果是第1行,读取数据 if dataRow == 1: self.double.send_double_license_applicant(data) self.double.check_ico_len(data[1]) self.loginElem.quit() except Exception as e: print("same_termina_approvel fail: ") + str(e) self.log.log_end("same_termina_approvel") u'''双人审批申请人已下线审批过期''' def termina_expired_approvel_003(self): self.comsuit.use_new_user_login() #日志开始记录 self.log.log_start("Expired_approvel") #获取双人审批申请的数据 dobData = self.get_double_data("double_license_sso") expData = self.get_double_data("termina_approvel") for dataRow in range(len(dobData)): data = dobData[dataRow] try: #如果不是第1行,读取数据 if dataRow == 2: self.double.send_double_license_applicant(data) number = self.acproval.get_new_process_number() self.loginElem.quit() self.double.approver_by_process_approval(expData, number) except Exception as e: print("Expired_approvel fail: ") + str(e) self.log.log_end("Expired_approvel") u'''双人审批审批人拒绝申请''' def termina_deny_approvel_004(self): self.comsuit.use_new_user_login() #日志开始记录 self.log.log_start("deny_double_approvel") #获取双人审批申请的数据 dobData = self.get_double_data("double_license_sso") expData = self.get_double_data("deny_approvel") for dataRow in range(len(dobData)): data = dobData[dataRow] try: #如果不是第1行,读取数据 if dataRow == 2: self.double.send_double_license_applicant(data) number = self.acproval.get_new_process_number() self.double.approver_remote_approval(expData, number) self.cmf.select_menu(u"运维操作", u"SSO") self.double.check_ico_len(data[1]) self.loginElem.quit() except Exception as e: print("deny_double_approvel fail: ") + str(e) self.log.log_end("deny_double_approvel") u'''双人审批审批人同意申请''' def termina_agree_approvel_005(self): self.comsuit.use_new_user_login() #日志开始记录 self.log.log_start("agree_double_approvel") #获取双人审批申请的数据 dobData = self.get_double_data("double_license_sso") expData = self.get_double_data("agree_approvel") for dataRow in range(len(dobData)): data = dobData[dataRow] try: #如果不是第1行,读取数据 if dataRow == 2: self.double.send_double_license_applicant(data) number = self.acproval.get_new_process_number() self.double.approver_remote_approval(expData, number) self.cmf.select_menu(u"运维操作", u"SSO") self.double.check_ico_len(data[1]) self.loginElem.quit() except Exception as e: print("agree_double_approvel fail: ") + str(e) self.log.log_end("agree_double_approvel") u'''访问审批流程任务查询''' def double_query_process_task_006(self): #日志开始记录 self.log.log_start("double_query_process_task") #获取流程任务查询的数据 taskData = self.get_double_data("process_task") for dataRow in range(len(taskData)): data = taskData[dataRow] try: #如果不是第1行,读取数据 if dataRow != 0: if dataRow == 1: self.acproval.user_login(data[1]) self.flow.query_process_task(data) self.log.log_detail(data[0], True) except Exception as e: print("double_query_process_task fail: ") + str(e) self.log.log_end("double_query_process_task") u'''访问审批个人历史查询''' def double_query_personal_history_007(self): #日志开始记录 self.log.log_start("double_query_personal_history") #获取个人历史查询的数据 perData = self.get_double_data("personal_history") for dataRow in range(len(perData)): data = perData[dataRow] try: #如果不是第1行,读取数据 if dataRow != 0: self.flow.query_personal_history(data) self.log.log_detail(data[0], True) except Exception as e: print("double_query_personal_history fail: ") + str(e) self.loginElem.quit() self.log.log_end("double_query_personal_history") u'''访问审批申请历史查询''' def double_query_apply_history_008(self): self.comsuit.use_new_user_login() #日志开始记录 self.log.log_start("double_query_apply_history") #获取申请历史查询的数据 applyData = self.get_double_data("apply_history") for dataRow in range(len(applyData)): data = applyData[dataRow] try: #如果不是第1行,读取数据 if dataRow != 0: self.flow.query_apply_history(data) self.log.log_detail(data[0], True) except Exception as e: print("double_query_apply_history fail: ") + str(e) self.log.log_end("double_query_apply_history") u'''访问审批全部历史查询''' def double_query_all_history_009(self): self.comsuit.dep_switch_to_sys() #日志开始记录 self.log.log_start("double_query_all_history") #获取全部历史查询的数据 allData = self.get_double_data("all_history") for dataRow in range(len(allData)): data = allData[dataRow] try: #如果不是第1行,读取数据 if dataRow != 0: self.flow.query_all_history(data) self.log.log_detail(data[0], True) except Exception as e: print("double_query_all_history fail: ") + str(e) self.log.log_end("double_query_all_history") u'''访问审批部门历史查询''' def double_query_department_history_010(self): self.comsuit.sys_switch_to_dep() #日志开始记录 self.log.log_start("double_query_department_history") #获取流程任务查询的数据 deprtData = self.get_double_data("department_history") for dataRow in range(len(deprtData)): data = deprtData[dataRow] try: #如果不是第1行,读取数据 if dataRow != 0: self.flow.query_department_history(data) self.log.log_detail(data[0], True) except Exception as e: print("double_query_department_history fail: ") + str(e) self.log.log_end("double_query_department_history")
class TimeRule(object): def __init__(self, driver): self.driver = driver self.getElem = getElement(driver) self.selectElem = selectElement(driver) self.frameElem = frameElement(driver) self.tableElem = tableElement(driver) self.cmf = commonFun(driver) self.cnEn = cnEncode() self.acproval = Accapproval(driver) self.user = UserPage(driver) u'''点击批量删除''' def click_bulkdel_time(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "delete_rule_time") u'''填写时间规则名称 Parameters: - rulename:时间规则名称 ''' def set_rulename(self, rulename): name = self.cnEn.is_float(rulename) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_clear("id", "fortRuleTimeName") self.getElem.find_element_wait_and_sendkeys("id", "fortRuleTimeName", name) u'''选择部门 Parameters: - deptname:部门名称 ''' def select_depart(self, deptname): name = self.cnEn.is_float(deptname) self.select_depart_right_common("department_name", "tree_1_switch", name) time.sleep(2) u'''启动日期 Parameters: - type:t代表今天,c代表clear,q代表确定,默认选择今天 - starttime:启动日期 ''' def start_date(self, types, starttime=None): time.sleep(2) self.frameElem.from_frame_to_otherFrame("rigthFrame") # 时间控件的fram的xpath # fxpath = "//iframe[@hidefocus='true']" fxpath = "/html/body/div/iframe" # 日期控件table的xpath路径 txpath = "/html/body/div/div[3]/table" status = self.cnEn.is_float('0') type = self.cnEn.is_float(types) if starttime != None: # 转成datetime对象 date = datetime(*xldate_as_tuple(starttime, 0)) start = date.strftime('%Y-%m-%d %H:%M:%S') self.option_time_rule("fortStartTime", fxpath, status, type, txpath, start) else: self.option_time_rule("fortStartTime", fxpath, status, type, txpath) u'''结束日期 Parameters: - type:t代表今天,c代表clear,q代表确定,默认选择今天 - endtime:结束日期设定的日期,格式为2016-9-7 11:42:42 ''' def date_of_termination(self, types, endtime): self.frameElem.from_frame_to_otherFrame("rigthFrame") # 时间控件的fram的xpath fxpath = "//iframe[@hidefocus='true']" # 日期控件table的xpath路径 txpath = "/html/body/div/div[3]/table" status = self.cnEn.is_float('0') type = self.cnEn.is_float(types) # 转成datetime对象 date = datetime(*xldate_as_tuple(endtime, 0)) end = date.strftime('%Y-%m-%d %H:%M:%S') self.option_time_rule("fortEndTime", fxpath, status, type, txpath, end) u'''设置状态类型 Parameters: - status: 状态类型0代表禁止使用,1代表允许使用 ''' def set_status_type(self, status): self.frameElem.from_frame_to_otherFrame("rigthFrame") statu = self.cnEn.is_float(status) selem = self.getElem.find_element_with_wait_EC("id", "fortAccessType") self.selectElem.select_element_by_value(selem, statu) u'''设置时间 Parameters: - method: 设置方式 option的value值 - weeks: 星期(可多选)option的value值 - hours: 小时(可多选) ''' def set_time(self, methods, weeks, hours='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") #设置时间方式 method = self.cnEn.is_float(methods) selem = self.getElem.find_element_with_wait_EC("id", "method") self.selectElem.select_element_by_value(selem, method) #设置日期 week = weeks.split() if methods == "weeks": for data in week: welem = self.getElem.find_element_with_wait_EC("id", "fortWeeks") self.selectElem.select_element_by_value(welem, data) elif methods == "days": for data in week: welem = self.getElem.find_element_with_wait_EC("id", "fortDays") self.selectElem.select_element_by_value(welem, data) if hours != 'no': #设置小时 hour = hours.split() for hr in hour: helem = self.getElem.find_element_with_wait_EC("id", "fortHours") self.selectElem.select_element_by_value(helem, hr) u'''取消时间 Parameters: - method: 设置方式 option的value值 - weeks: 星期(可多选)option的value值 - hours: 小时(可多选) ''' def deselect_time(self, methods, weeks, hours='no'): self.frameElem.from_frame_to_otherFrame("rigthFrame") #设置日期 week = weeks.split() if methods == "weeks": for data in week: welem = self.getElem.find_element_with_wait_EC("id", "fortWeeks") self.selectElem.deselect_element_by_value(welem, data) elif methods == "days": for data in week: welem = self.getElem.find_element_with_wait_EC("id", "fortDays") self.selectElem.deselect_element_by_value(welem, data) if hours != 'no': #设置小时 hour = hours.split() for hr in hour: helem = self.getElem.find_element_with_wait_EC("id", "fortHours") self.selectElem.deselect_element_by_value(helem, hr) u'''填写描述信息 Parameters: - descrip:描述信息 ''' def set_descrip(self, descrip): self.frameElem.from_frame_to_otherFrame("rigthFrame") description = self.cnEn.is_float(descrip) self.getElem.find_element_wait_and_clear("id", "fortDescription") self.getElem.find_element_wait_and_sendkeys("id", "fortDescription", description) u'''点击保存按钮''' def click_save_time(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "save_rule_time") u'''填写检索名称 Parameters: - timename:名称 ''' def set_search_timename(self, timename): self.frameElem.from_frame_to_otherFrame("rigthFrame") name = self.cnEn.is_float(timename) self.getElem.find_element_wait_and_clear("id", "fortRuleTimeName") self.getElem.find_element_wait_and_sendkeys("id", "fortRuleTimeName", name) u'''点击检索按钮''' def click_search_time(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "retFortRuleTimeName") u'''点击重置''' def click_reset_time(self): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC("id", "resetting") u'''点击编辑按钮 Parameters: - timename:时间规则名称 ''' def click_edit_time(self, timename): try: self.frameElem.from_frame_to_otherFrame("rigthFrame") row = self.acproval.find_name_by_row(timename, "fortRuleTimeName") update_xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(row) + "]/td[6]/input[1]" self.getElem.find_element_wait_and_click("xpath", update_xpath) except Exception: print("Click the Edit button to fail") u'''点击删除按钮 Parameters: - timename:时间规则名称 ''' def click_del_time(self, timename): try: self.frameElem.from_frame_to_otherFrame("rigthFrame") row = self.acproval.find_name_by_row(timename, "fortRuleTimeName") del_xpath = "/html/body/div/div[6]/div[2]/div/table/tbody/tr[" + str(row) + "]/td[6]/input[2]" self.getElem.find_element_wait_and_click("xpath", del_xpath) except Exception: print("Click the Del button to fail") u'''选择部门公共方法 parameter: - idname:填写框id - swithid:部门展开按钮id - deptname:部门名称 ''' def select_depart_right_common(self, idname, swithid, deptname): try: time.sleep(2) self.frameElem.from_frame_to_otherFrame("rigthFrame") self.getElem.find_element_wait_and_click_EC('id', idname) time.sleep(2) self.getElem.find_element_wait_and_click_EC('id', swithid) #获取所有a标签的对象 elems = self.driver.find_elements_by_tag_name("a") for elem in elems: elemtext = elem.get_attribute("title") elemid = elem.get_attribute("id") if deptname == elemtext: self.getElem.find_element_wait_and_click("id", elemid) break except Exception as e: print "Department select error:" + str(e) u'''操作时间控件 Parameters: - wdateId:日期控件input控件的ID值 - fxpath:日期控件frame的xpath路径 - status: 日期控件是否有时分秒 - txpath:日期控件table的xpath路径 - time:设定的日期,格式为2016-9-7 11:42:42 - type:t代表今天,c代表clear,q代表确定,默认选择今天 ''' def option_time_rule(self,wdateId,fxpath,status='0',type='t',txpath = None,dtime = None): self.getElem.find_element_wait_and_click("id",wdateId) frame = self.driver.find_element_by_xpath(fxpath) self.driver.switch_to_frame(frame) if type == 't': self.getElem.find_element_wait_and_click("id","dpTodayInput") elif type == 'c': self.getElem.find_element_wait_and_click("id","dpClearInput") elif type == 'q': if dtime is not None: list = dtime.split() ymdList = list[0].split("-") hmsList = list[1].split(":") #年 tYear = ymdList[0] #月 tMon = ymdList[1] #日 tDay = ymdList[2] #时 tHour = hmsList[0] #分 tMin = hmsList[1] #秒 tSen = hmsList[2] dTitle = self.getElem.find_element_with_wait("id","dpTitle").find_elements_by_tag_name("input") #设定月 dTitle[0].clear() dTitle[0].send_keys(tMon) #设定年 dTitle[1].clear() dTitle[1].send_keys(tYear) time.sleep(2) self.frameElem.from_frame_to_otherFrame("rigthFrame") if wdateId == "fortStartTime": self.getElem.find_element_wait_and_click_EC("id", "fortStartTime") elif wdateId == "fortEndTime": self.getElem.find_element_wait_and_click_EC("id", "fortEndTime") self.driver.switch_to_frame(frame) if txpath is not None: iStatus = False for itr in range(7): if itr != 0: for itd in range(7): ct = self.tableElem.get_table_cell_text(txpath,itr,itd)[0] #排除第一行大于7的 if itr == 1 and int(ct) > 7: continue #排除倒数第二行小于15的 if itr == 5 and int(ct) < 15: continue #排除最后一行小于15的 if itr == 6 and int(ct) < 15: continue #如果跟给定的日期一致,点击日期 if int(ct) == int(tDay): self.tableElem.get_table_cell_text(txpath,itr,itd)[1].click() iStatus = True break #找到日期后跳出循环 if iStatus: break #日期控件是否有时分秒 if status == '1': dTime = self.getElem.find_element_with_wait("id","dpTime").find_elements_by_tag_name("input") #设定小时 dTime[0].clear() dTime[0].send_keys(tHour) #设定分钟 dTime[2].clear() dTime[2].send_keys(tMin) #设定秒 dTime[4].clear() dTime[4].send_keys(tSen) self.getElem.find_element_wait_and_click("id","dpOkInput") u'''给用户添加时间规则 Parameters: - username:要编辑的用户名称 - timerule:时间规则test值 ''' def edit_user_time_rule(self, username, timerule): self.frameElem.from_frame_to_otherFrame("mainFrame") name = self.cnEn.is_float(username) self.user.operate_edit(name) self.user.click_advanced_option() self.select_time_rule(timerule) self.user.save_button() self.cmf.click_login_msg_button() self.user.click_back_button() u'''选择时间规则 Parameters: - timerule:时间规则test值 ''' def select_time_rule(self, timerule): self.frameElem.from_frame_to_otherFrame("mainFrame") timer = self.cnEn.is_float(timerule) select_elem = self.getElem.find_element_with_wait_EC('id',"fortRuleTimeId") self.selectElem.select_element_by_visible_text(select_elem, timer)
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")