def __init__(self, driver): self.driver = driver self.dataFile = dataFileName() self.cmf = commonFun(self.driver) self.initDriver = initDriver() self.loginElem = loginPage(self.driver) self.roleElem = Role(self.driver) self.userElem = UserPage(self.driver) self.frameElem = frameElement(self.driver) self.authElem = AuthMethodPage(self.driver) self.dptment = Department(self.driver) self.resource = Resource(self.driver) self.account = Accountmgr(self.driver) self.windowsElem = WindowsResource(self.driver) self.databaseElem = DatabaseResource(self.driver) self.usergroup = Usergroup(self.driver) self.regroup = Regroup(self.driver) self.appElem = AppPage(self.driver) self.authorizationElem = AuthorizationPage(self.driver) self.testAutho = testAuthorization(self.driver) self.clientElem = ClientPage(self.driver) self.command = CommandRule(self.driver) self.ntp = NtpService(self.driver) self.mail = MailPage(self.driver) self.syslog = Syslog(driver) self.ssoElem = SsoPage(self.driver) self.alarm = AlarmPage(self.driver) self.PwdStr = PwdStrategy(self.driver) self.passwdenvelope = EnvelopePage(self.driver)
def __init__(self, driver): self.driver = driver self.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)
def __init__(self,driver): self.driver = driver self.log = log() self.cmf = commonFun(driver) self.getElem = getElement(driver) self.cnEnde = cnEncode() self.ssoElem = SsoPage(self.driver) self.tableElem = tableElement(self.driver) self.selectElem = selectElement(driver) self.dataFile = dataFileName() self.frameElem = frameElement(self.driver) self.commSuite = CommonSuiteData(self.driver)
class CommonSuiteData(): def __init__(self, driver): self.driver = driver self.dataFile = dataFileName() self.cmf = commonFun(self.driver) self.initDriver = initDriver() self.loginElem = loginPage(self.driver) self.roleElem = Role(self.driver) self.userElem = UserPage(self.driver) self.frameElem = frameElement(self.driver) self.authElem = AuthMethodPage(self.driver) self.dptment = Department(self.driver) self.resource = Resource(self.driver) self.account = Accountmgr(self.driver) self.windowsElem = WindowsResource(self.driver) self.databaseElem = DatabaseResource(self.driver) self.usergroup = Usergroup(self.driver) self.regroup = Regroup(self.driver) self.appElem = AppPage(self.driver) self.authorizationElem = AuthorizationPage(self.driver) self.testAutho = testAuthorization(self.driver) self.clientElem = ClientPage(self.driver) self.command = CommandRule(self.driver) self.ntp = NtpService(self.driver) self.mail = MailPage(self.driver) self.syslog = Syslog(driver) self.ssoElem = SsoPage(self.driver) self.alarm = AlarmPage(self.driver) self.PwdStr = PwdStrategy(self.driver) self.passwdenvelope = EnvelopePage(self.driver) u'''切换模块 parameter: levelText1 : 一级模块名称 levelText2 : 二级模块名称 ''' def switch_to_moudle(self, levelText1, levelText2): time.sleep(2) self.frameElem.from_frame_to_otherFrame("topFrame") self.cmf.select_menu(levelText1) self.cmf.select_menu(levelText1, levelText2) #----------------------------------------用户相关------------------------------ u'''填写用户信息 parameters: data[1] : 用户名称 data[3] : 用户账号 data[4] : 用户密码 data[5] : 确认密码 data[6] : 开始时间 data[7] : 访问方式 data[8] : AD域账号 roleText : 用户角色 ''' def set_user_basic_info(self, data, roleText, status='no'): self.frameElem.from_frame_to_otherFrame("mainFrame") if status != 'no': self.userElem.add_role_button() else: self.userElem.add_button() self.userElem.set_user_account(data[3]) self.userElem.set_user_name(data[1]) self.userElem.set_user_pwd(data[4]) self.userElem.set_user_enquire_pwd(data[5]) self.userElem.set_start_time(data[6]) if data[12] != "": self.userElem.set_user_email(data[12]) if data[10] != "": self.userElem.set_dep(data[10]) if data[7] != "": #设置访问方式 self.userElem.click_advanced_option() self.userElem.set_auth_method_rule(data[7]) #访问方式不是默认方式 if int(data[7]) != 2: self.userElem.set_ad_name(data[8]) if data[9] != "": self.userElem.set_user_role(roleText) self.userElem.click_role_add_button() self.userElem.save_button() self.cmf.click_login_msg_button() u'''删除用户''' def del_user(self): self.switch_to_moudle(u"运维管理", u"用户") self.frameElem.from_frame_to_otherFrame("mainFrame") self.userElem.select_all_button() self.userElem.del_button() self.frameElem.switch_to_content() self.cmf.click_login_msg_button() self.cmf.click_login_msg_button() u'''用户退出''' def user_quit(self): self.loginElem.quit() #-----------------------------部门-------------------------------------------- u'''填写部门名称 parameters : data[0] : 部门名称 data[1] : 操作类型(添加:0) data[2] : 添加的部门名称 ''' def set_dep(self, data): self.switch_to_moudle(u"运维管理", u"组织定义") self.dptment.click_left_department() #点击展开按钮 self.dptment.click_dept_switch() self.dptment.click_basic_operation(data[0], int(data[1])) self.dptment.popup_sendkey(data[2]) self.dptment.click_ok_button() self.cmf.click_login_msg_button() def set_del_dep(self, data): self.switch_to_moudle(u"运维管理", u"组织定义") self.dptment.click_left_department() self.dptment.click_dept_switch() self.dptment.click_basic_operation(data[0], int(data[1])) self.cmf.click_login_msg_button() self.cmf.click_login_msg_button() #-----------------------------用户组------------------------------------------ u'''添加用户到用户组''' def set_user_to_group(self, data): # self.usergroup.click_left_usergroup() # self.usergroup.click_usergroup_switch() self.usergroup.click_usergroup_add_user(data[3], data[4]) self.regroup.check_depart(data[5]) self.usergroup.click_usergroup_add_user_query() self.regroup.check_all_resource() self.regroup.click_resource_okbutton() self.cmf.click_login_msg_button() u'''填写用户组信息 parameters: data[0] : 操作类型(添加:0) data[1] : 部门名称 data[2] : 编辑的用户组名称 data[3] : 添加的用户组名称 ''' def set_add_user_group(self, data): self.switch_to_moudle(u"运维管理", u"组织定义") self.usergroup.click_left_usergroup() self.usergroup.click_usergroup_switch() self.usergroup.usergroup_click_basic_operation(int(data[0]), data[1], data[2]) self.dptment.popup_sendkey(data[3]) self.dptment.click_ok_button() self.cmf.click_login_msg_button() if data[4] != "": self.set_user_to_group(data) u'''删除用户组 parameters : data[0] : 操作类型(删除:4) data[1] : 部门名称 data[2] : 删除的用户组名称 ''' def set_del_user_group(self, data): self.switch_to_moudle(u"运维管理", u"组织定义") self.usergroup.click_left_usergroup() self.usergroup.click_usergroup_switch() self.usergroup.usergroup_click_basic_operation(int(data[0]), data[1], data[2]) self.cmf.click_login_msg_button() self.cmf.click_login_msg_button() #-----------------------------资源组------------------------------------------ u'''添加资源到资源组''' def set_res_to_group(self, data): self.regroup.click_regroup_add_resouce(data[3], data[4]) self.regroup.check_depart(data[5]) self.regroup.click_regroup_add_resouce_query() self.regroup.check_all_resource() self.regroup.click_resource_okbutton() time.sleep(1) self.cmf.click_login_msg_button() u'''填写资源组信息 parameters: data[0] : 操作类型(添加:0) data[1] : 部门名称 data[2] : 编辑的资源组名称 data[3] : 添加的资源组名称 ''' def set_add_res_group(self, data): self.switch_to_moudle(u"运维管理", u"组织定义") self.regroup.click_left_regroup() self.regroup.click_regroup_switch() self.regroup.regroup_click_basic_operation(int(data[0]), data[1], data[2]) self.dptment.popup_sendkey(data[3]) self.dptment.click_ok_button() self.cmf.click_login_msg_button() if data[4] != "": self.set_res_to_group(data) u'''删除资源组 parameters : data[0] : 操作类型(删除:4) data[1] : 部门名称 data[2] : 删除的资源组名称 ''' def set_del_res_group(self, data): self.switch_to_moudle(u"运维管理", u"组织定义") self.regroup.click_left_regroup() self.regroup.click_regroup_switch() self.regroup.regroup_click_basic_operation(int(data[0]), data[1], data[2]) self.cmf.click_login_msg_button() self.cmf.click_login_msg_button() #-----------------------------资源-------------------------------------------- u'''填写资源基本信息 parameters : data[0]:资源类型 data[1]:资源名称 data[2]:资源IP data[3]:部门 ''' def set_resource_info(self, data): self.switch_to_moudle(u"运维管理", u"资源") self.frameElem.from_frame_to_otherFrame("mainFrame") self.resource.click_add_edit_button() self.resource.select_resource_type(data[0]) self.resource.set_resource_name(data[1]) self.resource.set_resource_ip(data[2]) if data[3] != 'no': time.sleep(5) self.resource.set_depart(data[3]) #选择协议 if data[4] != "": self.resource.select_agreement(data[4]) if data[5] != "": self.resource.click_account_sync() self.resource.set_admin_account(data[5]) self.resource.set_admin_pwd(data[6]) self.resource.set_confirm_pwd(data[7]) #提权口令 if data[8] != "": self.resource.click_up_super() self.resource.set_super_pwd(data[8]) self.resource.set_super_confirm_pwd(data[9]) #填写域名 if data[10] != "": self.databaseElem.set_domain_name(data[10]) #账号分类 if data[11] != "": self.resource.click_account_sync() self.windowsElem.select_account_type(data[11]) #归属域控主机 if data[12] != "": self.windowsElem.select_attach_domian(data[12]) #主机名 if data[13] != "": self.databaseElem.set_host_name(data[13]) self.resource.click_save_button() self.cmf.click_login_msg_button() time.sleep(3) # self.driver.implicitly_wait(3) self.cmf.back() u'''填写数据库基本信息''' def set_database_res_info(self, data): self.switch_to_moudle(u"运维管理", u"资源") self.frameElem.from_frame_to_otherFrame("mainFrame") self.resource.click_add_edit_button() self.resource.select_resource_type(data[2]) self.databaseElem.add_edit_database_resource(data) self.cmf.click_login_msg_button() time.sleep(3) self.cmf.back() u'''填写资源账号基本信息 parameters: data[1]:资源名称 data[4] : 账号编辑方式 data[5] : 账号名称 data[6] : 口令 data[7] : 确认口令 ''' def set_res_account(self, data): self.switch_to_moudle(u"运维管理", u"资源") self.account.click_account_manage_button(data[0]) time.sleep(1) self.account.click_account_add_edit_button(data[2]) self.account.select_edit_way(data[1]) if data[2] != "no": self.account.set_account_name(data[2]) self.account.set_account_pwd(data[3]) self.account.set_account_confirm_pwd(data[4]) self.account.set_authorize() self.account.click_save_account() self.cmf.click_login_msg_button() #-----------------------------授权---------------------------------------- u'''填写授权基本信息 parameters: data[1]:授权名称 data[2]:部门名称 data[3]:状态 ''' def set_authorization(self, data): self.switch_to_moudle(u'运维管理', u'授权') self.authorizationElem.add_button() self.authorizationElem.set_auth_name(data[1]) self.authorizationElem.set_dep(data[2], data[3]) self.authorizationElem.click_add_user() self.authorizationElem.set_select_user_search_button() self.authorizationElem.set_user_check_all_button() self.authorizationElem.set_ok_button() #添加资源 self.authorizationElem.click_add_res() self.authorizationElem.set_select_res_search_button() self.authorizationElem.set_res_check_all_button() self.authorizationElem.set_ok_button() self.authorizationElem.save_button() self.cmf.click_login_msg_button() self.cmf.back() #---------------------------------填写应用发布信息---------------------------- u'''填写应用发布信息''' def set_application_info(self, data): self.switch_to_moudle(u"系统配置", u"关联服务") self.appElem.app_module_button() self.appElem.click_add_button() self.appElem.set_name(data[0]) self.appElem.set_ip(data[1]) self.appElem.set_app_account(data[3]) self.appElem.set_pwd(data[4]) self.appElem.set_repwd(data[5]) self.appElem.ip_is_succ() self.appElem.click_save_button() self.cmf.click_login_msg_button() u'''删除应用发布''' def del_application(self, rowList): self.switch_to_moudle(u"系统配置", u"关联服务") self.appElem.app_module_button() self.frameElem.from_frame_to_otherFrame("rigthFrame") app_data = self.get_table_data("add_application") for dataRow in rowList: data = app_data[dataRow] if dataRow != 0: self.appElem.operate_del(data[0]) self.cmf.click_login_msg_button() self.cmf.click_login_msg_button() #-------------------------------------客户端----------------------------------- u'''填写客户端基本信息''' def set_client_info(self, data): #self.switch_to_moudle(u"系统配置",u"客户端配置") self.frameElem.from_frame_to_otherFrame("mainFrame") self.clientElem.add_button() self.clientElem.set_client_name(data[2]) self.clientElem.set_action_stream(data[3]) self.clientElem.set_database_res_type(data[0], data[1]) self.clientElem.save_button() u'''删除客户端''' def set_delete_client_info(self, data): #self.switch_to_moudle(u"系统配置",u"客户端配置") self.frameElem.from_frame_to_otherFrame("mainFrame") self.clientElem.select_query_res_type(data[0], data[1]) self.clientElem.click_query_button() self.clientElem.del_operation(data[2]) self.cmf.click_login_msg_button() #------------------------------资源账号授权------------------------------------ u'''添加用户和资源账号类型的授权''' def set_authorization_info(self, data): self.switch_to_moudle(u"运维管理", u"授权") self.testAutho.common_part(data) self.testAutho.add_user(data) self.authorizationElem.click_add_res_account() self.authorizationElem.set_select_res_ip(data[6]) self.authorizationElem.set_select_res_account(data[8]) self.authorizationElem.set_select_res_search_button() self.authorizationElem.set_res_check_all_button() self.authorizationElem.set_ok_button() self.authorizationElem.res_account_status() self.authorizationElem.save_button() self.cmf.click_login_msg_button() u'''删除授权''' def del_authorization(self): self.switch_to_moudle(u"运维管理", u"授权") self.frameElem.from_frame_to_otherFrame("mainFrame") self.authorizationElem.check_all() self.authorizationElem.del_button() self.cmf.click_login_msg_button() self.cmf.click_login_msg_button() #-----------------------------数据---------------------------------------- u'''获取数据 Parameters: - sheetname:sheet名称 return:表格数据 ''' def get_table_data(self, sheetname): filePath = self.dataFile.get_common_suite_test_data_url() fileData = self.dataFile.get_data(filePath, sheetname) return fileData u'''添加应用发布''' def add_application(self, rowList): app_data = self.get_table_data('add_application') for dataRow in rowList: data = app_data[dataRow] if dataRow != 0: self.set_application_info(data) u'''初始化用户登录''' def isomper_login(self): login_data = self.get_table_data('add_user') logindata = login_data[4] self.loginElem.login(logindata) u'''添加用户数据模板''' def add_user_data_module(self, rowList): self.switch_to_moudle(u"运维管理", u"用户") user_data = self.get_table_data("add_user") for dataRow in rowList: data = user_data[dataRow] if dataRow != 0: self.set_user_basic_info(data, data[9], data[13]) self.userElem.click_back_button() u'''添加系统管理员和部门管理员的用户''' def add_user_with_role(self): rowList = [1] self.add_user_data_module(rowList) u'''登录并切换至角色公用方法 parameters: login_status :'no'(登录状态:没有登录) ''' def login_and_switch_to_common(self, login_status='no'): login_data = self.get_table_data("add_user") logindata = login_data[1] if login_status == 'no': self.loginElem.login(logindata) #获取角色 roleList = logindata[9].split(',') return roleList u'''使用系统管理员登录系统''' def login_sysadmin(self): login_data = self.get_table_data('add_user') logindata = login_data[1] self.loginElem.login(logindata) u'''使用安全保密管理员登录系统''' def login_secadmin(self): login_data = self.get_table_data('add_user') logindata = login_data[2] self.loginElem.login(logindata) u'''使用安全审计员登录系统''' def login_sysaudit(self): login_data = self.get_table_data('add_user') logindata = login_data[3] self.loginElem.login(logindata) u'''用户登录系统''' def login_user(self, row): login_data = self.get_table_data('add_user') logindata = login_data[int(row)] self.loginElem.login(logindata) u'''切换至运维操作员''' def switch_to_operation(self): self.cmf.select_role_by_text(u"运维操作员") #使用新添加的用户登录 def use_new_user_login(self): login_data = self.get_table_data("add_user") logindata = login_data[1] time.sleep(2) self.loginElem.login(logindata) u'''运维管理员登录''' def sso_user_login(self, rowList): login_data = self.get_table_data("add_user") logindata = login_data[rowList] time.sleep(1) self.loginElem.login(logindata) u'''运维管理员AD域方式登录''' def sso_user_ad_login(self, rowList): login_data = self.get_table_data("add_user") logindata = login_data[rowList] self.frameElem.switch_to_content() self.loginElem.set_login_method(logindata[2]) self.loginElem.set_ad_login_username(logindata[3]) self.loginElem.set_ad_login_pwd(logindata[11]) time.sleep(1) self.loginElem.click_login_button() u'''添加认证配置''' def add_meth_method(self): meth_data = self.get_table_data("meth_method") methData = meth_data[1] self.switch_to_moudle(u"策略配置", u"认证强度") self.authElem.select_all_auth(methData) u'''会话配置,设置最大登录数''' def set_login_max_num(self): self.loginElem.set_max_login_count() u'''添加登录测试数据''' def add_login_data(self): rowList = [2, 3, 4, 5, 6, 7] self.add_user_data_module(rowList) u'''添加授权用户''' def add_authorization_user(self): rowList = [8, 9, 10, 11, 12] self.add_user_data_module(rowList) u'''添加应用发布用户''' def add_app_user(self): rowList = [3] self.add_user_data_module(rowList) u'''添加单点登录用户''' def add_sso_user(self): rowList = [6, 8, 9, 10, 11, 13] self.add_user_data_module(rowList) u'''添加部门''' def add_dep(self, rowList): dep_data = self.get_table_data("add_dep") for dataRow in rowList: data = dep_data[dataRow] if dataRow != 0: self.set_dep(data) u'''删除部门''' def del_dep(self, rowList): dep_data = self.get_table_data("del_dep") for dataRow in rowList: data = dep_data[dataRow] if dataRow != 0: self.set_del_dep(data) u'''增加资源数据模板''' def add_resource_modele(self, rowList): res_data = self.get_table_data("add_res") for dataRow in rowList: data = res_data[dataRow] if dataRow != 0: self.set_resource_info(data) u'''添加授权资源''' def add_resource(self): rowList = [1, 2] self.add_resource_modele(rowList) u'''添加sso资源''' def add_sso_resource(self): #rowList = [1,2,3,4,5,7,8] rowList = [1, 3, 4, 5] self.add_resource_modele(rowList) u'''添加依附操作系统''' def add_database_resource(self): rowList = [2] self.add_resource_modele(rowList) u'''添加资源账号数据模板''' def add_res_account_module(self, rowList): account_data = self.get_table_data("res_account") for dataRow in rowList: data = account_data[dataRow] if dataRow != 0: self.set_res_account(data) u'''添加授权资源账号''' def add_res_account(self): rowList = [1, 3] self.add_res_account_module(rowList) u'''添加sso资源账号''' def add_sso_res_account(self): rowList = [1, 2, 4, 5, 6, 7] #rowList = [1,2,3,4,5,6,7,9,10] self.add_res_account_module(rowList) u'''添加用户组''' def add_user_group(self, rowList): user_group_data = self.get_table_data("add_user_group") for dataRow in rowList: data = user_group_data[dataRow] if dataRow != 0: self.set_add_user_group(data) u'''删除用户组''' def del_user_group(self, rowList): user_group_data = self.get_table_data("del_user_group") for dataRow in rowList: data = user_group_data[dataRow] if dataRow != 0: self.set_del_user_group(data) u'''添加资源组''' def add_res_group(self, rowList): res_group_data = self.get_table_data("add_res_group") for dataRow in rowList: data = res_group_data[dataRow] if dataRow != 0: self.set_add_res_group(data) u'''删除资源组''' def del_res_group(self, rowList): res_group_data = self.get_table_data("del_res_group") for dataRow in rowList: data = res_group_data[dataRow] if dataRow != 0: self.set_del_res_group(data) u'''添加授权''' def add_authrization(self, rowList): auth_data = self.get_table_data("add_authorization") for dataRow in rowList: data = auth_data[dataRow] if dataRow != 0: self.set_authorization(data) u'''添加授权数据模板''' def add_authorization_module(self, rowList): autho_data = self.get_table_data("add_account_auth") for dataRow in rowList: data = autho_data[dataRow] if dataRow != 0: self.set_authorization_info(data) self.authorizationElem.back_button() u'''添加单点登录授权''' def add_sso_authorization(self): rowList = [1] #rowList = [1,2,3,4,5,6,7] self.add_authorization_module(rowList) u'''单点登录模板''' def sso_module(self, rowList): sso_data = self.get_table_data("sso") for dataRow in rowList: data = sso_data[dataRow] if dataRow != 0: self.frameElem.from_frame_to_otherFrame("rigthFrame") self.ssoElem.select_account(data[0], data[1]) self.ssoElem.select_sso_icon(data[0], data[2]) if data[3] != "": self.ssoElem.select_protocol(data[3]) #self.ssoElem.execute_chrome_key() self.ssoElem.choice_browser(data[2], data[4], data[5], data[6]) u'''添加客户端数据模板''' def add_client_module(self, rowList): client_data = self.get_table_data("add_client") self.switch_to_moudle(u"系统配置", u"客户端配置") for dataRow in rowList: data = client_data[dataRow] if dataRow != 0: self.set_client_info(data) u'''删除客户端数据模板''' def del_client_module(self, rowList): client_data = self.get_table_data("del_client") self.switch_to_moudle(u"系统配置", u"客户端配置") for dataRow in rowList: data = client_data[dataRow] if dataRow != 0: self.set_delete_client_info(data) u'''添加数据库资源模板''' def add_database_res_module(self, rowList): database_data = self.get_table_data("add_database") for dataRow in rowList: data = database_data[dataRow] if dataRow != 0: self.set_database_res_info(data) u'''删除用户数据模板''' def del_user_data_module(self, rowList): self.switch_to_moudle(u"运维管理", u"用户") self.frameElem.from_frame_to_otherFrame("mainFrame") user_data = self.get_table_data("add_user") for dataRow in rowList: data = user_data[dataRow] if dataRow != 0: self.switch_to_moudle(u"运维管理", u"用户") self.userElem.operate_delete(data[1]) self.frameElem.switch_to_content() self.cmf.click_login_msg_button() self.cmf.click_login_msg_button() u'''添加密码策略数据模板''' def add_strategy_data_module(self, rowList): self.switch_to_moudle(u"策略配置", u"密码策略") self.frameElem.from_frame_to_otherFrame("mainFrame") pwd_data = self.get_table_data("add_strategy") for dataRow in rowList: data = pwd_data[dataRow] if dataRow != 0: self.PwdStr.add_pwd_button() self.PwdStr.set_pwd_name(data[1]) self.PwdStr.term_of_validity(data[2]) self.PwdStr.password_length_min(data[3]) self.PwdStr.password_length_max(data[4]) self.PwdStr.set_lower_case(data[5]) self.PwdStr.set_capital(data[6]) self.PwdStr.set_minimum_digital(data[7]) self.PwdStr.set_Minimum_symbol(data[8]) self.PwdStr.save_button() self.frameElem.switch_to_content() self.cmf.click_msg_button(1) self.PwdStr.return_button() u'''删除密码策略数据模板''' def del_strategy_data_module(self, rowList): self.switch_to_moudle(u"策略配置", u"密码策略") self.frameElem.from_frame_to_otherFrame("mainFrame") pwd_data = self.get_table_data("add_strategy") for dataRow in rowList: data = pwd_data[dataRow] if dataRow != 0: self.PwdStr.del_sing_strategy(data[1]) self.frameElem.switch_to_content() self.cmf.click_login_msg_button() self.cmf.click_login_msg_button() u'''删除资源数据模板''' def del_resource_modele(self, rowList): self.switch_to_moudle(u"运维管理", u"资源") self.frameElem.from_frame_to_otherFrame("mainFrame") res_data = self.get_table_data("add_res") for dataRow in rowList: data = res_data[dataRow] if dataRow != 0: self.resource.click_del_button(data[1]) self.frameElem.switch_to_content() self.cmf.click_login_msg_button() self.cmf.click_login_msg_button() u'''删除授权数据模板''' def del_authorization_module(self, rowList): self.switch_to_moudle(u'运维管理', u'授权') self.frameElem.from_frame_to_otherFrame("mainFrame") autho_data = self.get_table_data("add_account_auth") for dataRow in rowList: data = autho_data[dataRow] if dataRow != 0: self.authorizationElem.click_auth_checkbox(data[2]) self.authorizationElem.del_button() self.frameElem.switch_to_content() self.cmf.click_login_msg_button() self.cmf.click_login_msg_button() #-------------------------------添加涉密版用户前置条件--------------------------------------- u'''前置条件通用''' def secret_user_prefix_condition(self): self.isomper_login() self.switch_to_moudle(u'角色管理', u'角色定义') #------------------------------部门前置条件----------------------------------- def depart_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() #切换到组织定义 self.switch_to_moudle(u"运维管理", u"组织定义") #------------------------------资源组前置条件----------------------------------- def regroup_module_prefix_condition(self): #使用安全保密管理员登录 self.login_secadmin() #添加资源 self.add_resource_modele([9, 6]) self.user_quit() #使用系统管理员登录 self.login_sysadmin() #切换到组织定义 self.switch_to_moudle(u"运维管理", u"组织定义") def regroup_module_post_condition(self): self.user_quit() #使用安全保密管理员登录 self.login_secadmin() #删除资源 self.del_resource_modele([9, 6]) self.user_quit() #------------------------------用户组前置条件----------------------------------- def usergroup_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() #添加用户 self.add_user_data_module([5, 6, 7, 8]) #切换到组织定义 self.switch_to_moudle(u"运维管理", u"组织定义") def usergroup_module_post_condition(self): self.del_user_data_module([5, 6, 7, 8]) self.user_quit() #------------------------------NTP服务前置条件--------------------------------- def ntp_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() #切换到NTP服务 self.switch_to_moudle(u'系统配置', u'关联服务') self.ntp.click_left_moudle(0) #-------------------------------SYSLOG前置条件--------------------------------- def syslog_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() #切换到NTP服务 self.switch_to_moudle(u'系统配置', u'关联服务') self.ntp.click_left_moudle(1) #------------------------------邮件前置条件--------------------------------- def mail_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() #切换到邮件服务 self.switch_to_moudle(u'系统配置', u'关联服务') self.mail.click_left_moudle_test() #------------------------------密码信封前置条件--------------------------------- def passwd_envelope_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() #切换到邮件服务 self.switch_to_moudle(u'系统配置', u'关联服务') self.passwdenvelope.click_left_moudle_envelope() #-------------------------------应用发布后置条件------------------------------- def application_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() self.add_user_data_module([9, 10]) self.switch_to_moudle(u"系统配置", u"关联服务") def application_module_post_condition(self): self.del_user_data_module([9, 10]) self.user_quit() #-------------------------------网卡配置前置条件------------------------------- def network_card_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() #切换到网卡配置 self.switch_to_moudle(u'系统配置', u'网络配置') #-------------------------------路由配置前置条件------------------------------- def routing_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() #切换到路由配置 self.cmf.select_menu(u'系统配置', u'网络配置', u'路由配置') #------------------------------备份还原前置条件----------------------------------- def backup_restore_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() #-----------------------------客户端配置前置条件------------------------------ def client_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() self.switch_to_moudle(u"系统配置", u"客户端配置") #-----------------------------AD域抽取前置条件------------------------------ def ad_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() self.add_user_data_module([18]) self.switch_to_moudle(u"系统配置", u"AD定时抽取") u'''AD域抽取后置条件''' def ad_module_post_condition(self): self.del_user_data_module([18]) self.user_quit() #------------------------------使用授权前置条件--------------------------------- def use_auth_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() self.switch_to_moudle(u'系统配置', u'使用授权') #------------------------------用户模块前置条件-------------------------------- u'''用户模块前置条件''' def user_module_prefix_condition(self): #使用系统管理员登录 self.login_sysadmin() self.switch_to_moudle(u'运维管理', u'用户') #--------------------------认证方式前置条件------------------------------------ u'''认证方式前置条件''' def auth_method_prefix_condition(self): #使用安全保密管理员登录 self.login_secadmin() self.add_user_data_module([11]) self.switch_to_moudle(u"策略配置", u"认证强度") self.frameElem.from_frame_to_otherFrame("mainFrame") u'''认证方式后置条件''' def auth_method_post_condition(self): self.del_user_data_module([11]) self.user_quit() #---------------------------------登录模块前置条件----------------------------- u'''登录模块前置条件''' def login_module_prefix_condition(self): #使用安全保密管理员登录 self.login_secadmin() #配置认证方式 self.add_meth_method() #配置最大登录数 self.set_login_max_num() #添加登录用户数据 self.add_user_data_module([12, 13, 14, 15, 16, 17]) #改变a的状态为关 self.userElem.change_user_status_off("gyrlogin2") #系统管理员退出 self.user_quit() u'''登录模块后置条件''' def login_module_post_condition(self): #使用安全保密管理员登录 self.login_secadmin() #删除认证方式 self.authElem.del_auth_method() self.del_user_data_module([12, 13, 14, 15, 16, 17]) self.user_quit() #------------------------------告警策略前置条件--------------------------------- def alarm_strategy_module_prefix_condition(self): #使用安全保密管理员登录 self.login_secadmin() def alarm_strategy_module_post_condition(self): self.alarm.del_command_config() self.alarm.del_default_config() self.alarm.del_auth_config() self.user_quit() #------------------------------会话配置前置条件-------------------------------- def session_module_prefix_condition(self): #使用安全保密管理员登录 self.login_secadmin() self.switch_to_moudle(u"策略配置", u"会话配置") #------------------------------密码策略前置条件-------------------------------- def pwdstr_module_prefix_condition(self): #使用安全保密管理员登录 self.login_secadmin() #添加资源 self.add_resource_modele([14]) self.add_user_data_module([19]) self.switch_to_moudle(u"策略配置", u"密码策略") def pwdstr_module_post_condition(self): self.del_resource_modele([14]) self.del_user_data_module([19]) self.user_quit() #------------------------------linux资源前置条件----------------------------------- def linuxre_module_prefix_condition(self): #使用安全保密管理员登录 self.login_secadmin() #添加密码策略 self.add_strategy_data_module([1]) #切换到资源 self.switch_to_moudle(u"运维管理", u"资源") def linuxre_module_post_condition(self): #删除密码策略 self.del_strategy_data_module([1]) self.user_quit() #------------------------------network资源前置条件----------------------------------- def networkre_module_prefix_condition(self): #使用安全保密管理员登录 self.login_secadmin() #切换到资源 self.switch_to_moudle(u"运维管理", u"资源") #------------------------------windows资源前置条件----------------------------------- def windowre_module_prefix_condition(self): #使用安全保密管理员登录 self.login_secadmin() #添加密码策略 self.add_strategy_data_module([2]) #切换到资源 self.switch_to_moudle(u"运维管理", u"资源") def windowre_module_post_condition(self): #删除密码策略 self.del_strategy_data_module([2]) self.user_quit() #-----------------------------数据库前置条件---------------------------------- def database_resource_prefix_condition(self): self.login_sysadmin() #添加应用发布 self.add_application([1]) self.user_quit() #使用安全保密管理员登录 self.login_secadmin() self.add_resource_modele([17]) self.switch_to_moudle(u"运维管理", u"资源") def database_resource_post_condition(self): self.del_resource_modele([17]) self.user_quit() self.login_sysadmin() self.del_application([1]) self.user_quit() #------------------------------授权前置条件----------------------------------- def authori_module_prefix_condition(self): #使用安全保密管理员登录 self.login_secadmin() self.add_resource_modele([15, 16]) self.add_res_account_module([18, 19]) self.user_quit() self.login_sysadmin() #添加授权用户 self.add_user_data_module([20, 21, 22, 23, 24]) self.add_res_group([1]) self.add_user_group([1]) self.user_quit() self.login_secadmin() self.switch_to_moudle(u'运维管理', u'授权') def authori_module_post_condition(self): self.del_resource_modele([15, 16]) self.user_quit() self.login_sysadmin() self.del_res_group([1]) self.del_user_group([1]) self.del_user_data_module([20, 21, 22, 23, 24]) self.user_quit() #------------------------------命令规则前置条件----------------------------------- def commandrule_module_prefix_condition(self): self.login_sysadmin() #添加用户 self.add_user_data_module([25]) self.user_quit() self.login_secadmin() #添加资源 self.add_resource_modele([3]) #添加资源账号 self.add_res_account_module([4]) #添加授权 self.add_authorization_module([2]) #切换到规则定义 self.switch_to_moudle(u'运维管理', u'规则定义') self.command.click_left_rule(0) def commandrule_module_post_condition(self): #删除授权 self.del_authorization_module([2]) #删除资源 self.del_resource_modele([3]) self.user_quit() self.login_sysadmin() #删除用户 self.del_user_data_module([25]) self.user_quit() #------------------------------时间规则前置条件----------------------------------- def timerule_module_prefix_condition(self): self.login_secadmin() #添加用户 self.add_user_data_module([26, 27, 28, 29, 30]) #切换到规则定义 self.switch_to_moudle(u'运维管理', u'规则定义') self.command.click_left_rule(1) def timerule_module_post_condition(self): #删除用户 self.del_user_data_module([26, 27, 28, 29, 30]) self.user_quit() #------------------------------地址规则前置条件----------------------------------- def addressrule_module_prefix_condition(self): self.login_secadmin() #添加用户 self.add_user_data_module([31, 32, 33, 34, 35, 36, 37, 38]) #切换到规则定义 self.switch_to_moudle(u'运维管理', u'规则定义') self.command.click_left_rule(2) def addressrule_module_post_condition(self): self.del_user_data_module([31, 32, 33, 34, 35, 36, 37, 38]) self.user_quit() #------------------------------资源时间规则前置条件----------------------------------- def retimerule_module_prefix_condition(self): self.login_sysadmin() #添加用户 self.add_user_data_module([39]) self.user_quit() self.login_secadmin() #添加资源 self.add_resource_modele([4, 5, 10]) #添加资源账号 self.add_res_account_module([5, 6, 14]) self.add_authorization_module([6]) #切换到规则定义 self.switch_to_moudle(u'运维管理', u'规则定义') self.command.click_left_rule(3) def retimerule_module_post_condition(self): self.user_quit() self.login_sysadmin() #删除用户 self.del_user_data_module([39]) self.user_quit() self.login_secadmin() #删除资源 self.del_resource_modele([4, 5, 10]) #删除授权 self.del_authorization_module([6]) self.user_quit() #------------------------------流程前置条件----------------------------------- def process_module_prefix_condition(self): self.login_sysadmin() #添加用户 self.add_user_data_module([40, 41, 42, 43, 44]) self.user_quit() self.login_secadmin() #添加资源 self.add_resource_modele([11, 12]) #添加资源账号 self.add_res_account_module([15, 16]) self.add_authrization([1]) def process_module_post_condition(self): #删除授权 self.del_authorization_module([7]) #删除资源 self.del_resource_modele([11, 12]) self.user_quit() self.login_sysadmin() #删除用户 self.del_user_data_module([40, 41, 42, 43, 44]) self.user_quit() #------------------------------双人授权前置条件----------------------------------- def dualmandate_module_prefix_condition(self): self.login_sysadmin() #添加用户 self.add_user_data_module([45, 46]) self.user_quit() self.login_secadmin() #添加资源 self.add_resource_modele([13]) #添加资源账号 self.add_res_account_module([17]) #添加授权 self.add_authrization([4]) def dualmandate_module_post_condition(self): #删除授权 self.del_authorization_module([8]) #删除资源 self.del_resource_modele([13]) self.user_quit() self.login_sysadmin() #删除用户 self.del_user_data_module([45, 46]) self.user_quit() #-----------------------------行为报表前置条件--------------------------------- def opt_report_module_prefix_condition(self): self.login_secadmin() self.add_resource_modele([18]) self.user_quit() self.login_sysadmin() self.add_user_data_module([47]) self.add_res_group([2]) self.add_user_group([2]) self.user_quit() self.login_sysaudit() self.switch_to_moudle(u"报表管理", u"审计报表") def opt_report_module_post_condition(self): self.user_quit() self.login_secadmin() self.del_resource_modele([18]) self.user_quit() self.login_sysadmin() self.del_user_data_module([47]) self.del_res_group([2]) self.del_user_group([2]) self.user_quit() #-----------------------------配置报表前置条件--------------------------------- def conf_report_module_prefix_condition(self): self.login_sysadmin() self.add_user_data_module([48]) self.add_user_group([3]) self.user_quit() self.login_sysaudit() self.switch_to_moudle(u"报表管理", u"审计报表") def conf_report_module_post_condition(self): self.user_quit() self.login_sysadmin() self.del_user_data_module([48]) self.del_user_group([3]) self.user_quit() #-----------------------------配置审计前置条件------------------------------ def system_log_prefix_condition(self): self.login_sysadmin() self.add_user_data_module([49]) self.switch_to_moudle(u"系统配置", u"关联服务") self.ntp.click_left_moudle(1) #填写syslog信息 self.frameElem.from_frame_to_otherFrame("rigthFrame") self.syslog.set_ip("172.16.10.11") self.syslog.set_ident("aa") self.syslog.save_button() self.cmf.click_login_msg_button() self.user_quit() self.login_sysaudit() self.switch_to_moudle(u"审计管理", u"配置审计") def system_log_post_condition(self): self.user_quit() self.login_sysadmin() self.del_user_data_module([49]) self.user_quit() #-----------------------------运维审计前置条件------------------------------ def audit_log_prefix_condition(self): self.login_and_switch_to_dep() self.add_user_data_module([43]) self.add_resource_modele([22]) self.add_res_account_module([20]) self.add_authorization_module([9]) self.switch_to_operation() self.sso_module([1]) self.user_quit() #新添加的运维管理员登录 self.sso_user_login(43) self.sso_module([1]) #新添加的运维管理员退出 self.user_quit() self.login_and_switch_to_sys() self.switch_to_moudle(u"审计管理", u"运维审计") def audit_log_post_condition(self): self.sys_switch_to_dep() self.del_authorization_module([9]) self.del_resource_modele([22]) self.del_user_data_module([43]) self.user_quit() #------------------------------命令单点登录前置条件---------------------------- u'''单点登录前置条件''' def sso_prefix_condition(self): self.login_and_switch_to_dep() self.add_resource_modele([1, 3, 4, 5]) self.add_res_account_module([1, 2, 4, 5, 6, 7]) self.add_authorization_module([1]) self.switch_to_operation() #self.user_quit() #self.login_and_switch_to_common() u'''单点登录后置条件''' def sso_post_condition(self): self.user_quit() self.login_and_switch_to_dep() self.del_resource_modele([1, 3, 4, 5]) self.del_authorization_module([1]) self.user_quit() #------------------------------windows单点登录前置条件------------------------- u'''windows单点登录前置条件''' def windows_sso_prefix_condition(self): self.login_and_switch_to_sys() #配置认证方式 self.add_meth_method() self.add_user_data_module([42]) self.sys_switch_to_dep() #self.login_and_switch_to_dep() self.add_resource_modele([2, 7, 8]) self.add_res_account_module([3, 9, 10]) self.add_authorization_module([3, 4]) self.switch_to_operation() #self.user_quit() #self.login_and_switch_to_common() u'''单点登录后置条件''' def windows_sso_post_condition(self): self.user_quit() self.login_and_switch_to_dep() self.del_authorization_module([3, 4]) self.del_user_data_module([42]) self.del_resource_modele([8, 7, 2]) self.user_quit() #------------------------------数据库单点登录前置条件------------------------- u'''数据库单点登录前置条件''' def database_sso_prefix_condition(self): #使用公共用户登录系统 self.login_and_switch_to_sys() #添加应用发布 self.add_application([2]) #添加客户端 self.add_client_module([1, 2]) self.sys_switch_to_dep() self.add_database_res_module([1, 2, 3]) self.add_res_account_module([11, 12, 13]) self.add_authorization_module([5]) self.switch_to_operation() u'''数据库单点登录后置条件''' def database_sso_post_condition(self): self.user_quit() self.login_and_switch_to_dep() self.del_authorization_module([5]) self.del_resource_modele([19, 20, 21]) self.dep_switch_to_sys() self.del_application([2]) self.del_client_module([1, 2]) self.user_quit()
class testSso(): def __init__(self,driver): self.driver = driver self.log = log() self.cmf = commonFun(driver) self.getElem = getElement(driver) self.cnEnde = cnEncode() self.ssoElem = SsoPage(self.driver) self.tableElem = tableElement(self.driver) self.selectElem = selectElement(driver) self.dataFile = dataFileName() self.frameElem = frameElement(self.driver) self.commSuite = CommonSuiteData(self.driver) u'''获取测试数据 Parameters: - sheetname:sheet名称 return:表格数据 ''' def get_table_data(self,sheetname): dataFile = dataFileName() filePath = dataFile.get_sso_test_url() ssoFileData = dataFile.get_data(filePath,sheetname) return ssoFileData u'''命令单点登录通用部分''' def sso_common_func(self,data): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.ssoElem.select_account(data[2],data[3]) self.ssoElem.select_sso_icon(data[2],data[4]) if data[5] != "": self.ssoElem.select_protocol(data[5]) #self.ssoElem.execute_chrome_key() self.ssoElem.choice_browser(data[4],data[6],data[7],data[8]) #self.ssoElem.refresh_windows() #判断测试项是否通过 self.log.log_detail(data[0], True) #清空标识状态 flag = False u'''windows资源单点登录通用部分''' def windows_common_func(self,data): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.ssoElem.select_account(data[2],data[3]) self.ssoElem.select_sso_icon(data[2],data[4]) if data[3] == "$user" or data[3] == "$user(local)": self.ssoElem.set_mstsc_account(data[9]) self.ssoElem.set_mstsc_pwd(data[10]) self.cmf.click_login_msg_button() self.ssoElem.choice_browser(data[4],data[6],data[7],data[8]) #判断测试项是否通过 self.log.log_detail(data[0], True) time.sleep(4) u'''cisco资源单点登录''' def cisco_sso_login_001(self): #日志开始记录 self.log.log_start("ssoLogin") #获取单点登录的数据 sso_data = self.get_table_data("sso") #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(sso_data)): data = sso_data[dataRow] try: #如果不是第一行标题,则读取数据 #if dataRow == 2: if 0 < dataRow <= 4: self.sso_common_func(data) except Exception as e: print ("Cisco SSO login fail: ") + str(e) #self.commSuite.user_quit() self.log.log_end("CiscossoLogin") u'''cisco匿名单点登录''' def cisco_niming_sso_login_002(self): #日志开始记录 self.log.log_start("nimingssoLogin") #获取单点登录的数据 sso_data = self.get_table_data("sso") #self.commSuite.sso_user_login(8) #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(sso_data)): data = sso_data[dataRow] try: #如果不是第一行标题,则读取数据 if 4 < dataRow <= 6: self.sso_common_func(data) except Exception as e: print ("niming SSO login fail: ") + str(e) #self.commSuite.user_quit() self.log.log_end("nimingssoLogin") u'''华为资源单点登录''' def huawei_sso_login_003(self): #日志开始记录 self.log.log_start("huaweissoLogin") #self.commSuite.sso_user_login(9) #无检查点的测试项标识,如果为True说明通过 sso_data = self.get_table_data("sso") flag = False for dataRow in range(len(sso_data)): data = sso_data[dataRow] try: #如果不是第一行标题,则读取数据 if 6 < dataRow <= 10 : self.sso_common_func(data) except Exception as e: print ("hauwei SSO login fail: ") + str(e) #self.commSuite.user_quit() self.log.log_end("huaweissoLogin") u'''linux资源单点登录''' def debian_sso_login_004(self): #日志开始记录 self.log.log_start("debianssoLogin") #self.commSuite.sso_user_login(10) sso_data = self.get_table_data("sso") #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(sso_data)): data = sso_data[dataRow] try: #如果不是第一行标题,则读取数据 if 11 <= dataRow <= 16 : self.sso_common_func(data) except Exception as e: print ("debian SSO login fail: ") + str(e) #self.commSuite.user_quit() self.log.log_end("debianssoLogin") u'''windowsRdp单点登录''' def windows_sso_login_005(self): #日志开始记录 self.log.log_start("windowsssoLogin") #self.commSuite.sso_user_login(11) sso_data = self.get_table_data("windows_sso") #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(sso_data)): data = sso_data[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0 : self.windows_common_func(data) except Exception as e: print ("Windows SSO login fail: ") + str(e) self.commSuite.user_quit() self.log.log_end("WindowsssoLogin") u'''domain资源单点登录''' def domain_sso_login_006(self): #日志开始记录 self.log.log_start("DomainssoLogin") self.commSuite.sso_user_ad_login(42) sso_data = self.get_table_data("domain_sso") #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(sso_data)): data = sso_data[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0 : self.windows_common_func(data) except Exception as e: print ("Domain SSO login fail: ") + str(e) #self.commSuite.user_quit() self.log.log_end("DomainssoLogin") u'''域内资源单点登录''' def yunei_sso_login_007(self): #日志开始记录 self.log.log_start("yuneissoLogin") #self.commSuite.sso_user_ad_login(13) sso_data = self.get_table_data("yunei_sso") #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(sso_data)): data = sso_data[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow != 0 : self.windows_common_func(data) except Exception as e: print ("yunei SSO login fail: ") + str(e) #self.commSuite.user_quit() self.log.log_end("yuneissoLogin") #if __name__ == "__main__": # browser = setDriver().set_local_driver() # # commonSuite = CommonSuiteData(browser) #commonSuite.sso_prefix_condition() #commonSuite.sso_post_condition() # #commonSuite.login_and_switch_to_common() # # ssoTest = testSso(browser) # ssoTest.cisco_sso_login_001() # ssoTest.cisco_niming_sso_login_002() # ssoTest.huawei_sso_login_003() # #ssoTest.debian_sso_login_004() # ssoTest.windows_sso_login_005() #ssoTest.domain_sso_login_006()
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 testDatabaseSso(): def __init__(self,driver): self.driver = driver self.log = log() self.cmf = commonFun(driver) self.getElem = getElement(driver) self.cnEnde = cnEncode() self.ssoElem = SsoPage(self.driver) self.tableElem = tableElement(self.driver) self.selectElem = selectElement(driver) self.dataFile = dataFileName() self.frameElem = frameElement(self.driver) self.commSuite = CommonSuiteData(self.driver) u'''获取测试数据 Parameters: - sheetname:sheet名称 return:表格数据 ''' def get_table_data(self,sheetname): dataFile = dataFileName() filePath = dataFile.get_sso_test_url() ssoFileData = dataFile.get_data(filePath,sheetname) return ssoFileData u'''资源单点登录通用部分''' def database_common_func(self,data): self.frameElem.from_frame_to_otherFrame("rigthFrame") self.ssoElem.select_account(data[2],data[3]) self.ssoElem.select_app_and_sso_icon(data[2],data[4],data[5]) self.ssoElem.choice_browser(data[5],data[6],data[7],data[8]) #判断测试项是否通过 self.log.log_detail(data[0], True) time.sleep(1) u'''oracle资源单点登录''' def oracle_sso_login_001(self): #日志开始记录 self.log.log_start("OraclessoLogin") sso_data = self.get_table_data("database_sso") #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(sso_data)): data = sso_data[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow == 1 : self.database_common_func(data) except Exception as e: print ("oracle SSO login fail: ") + str(e) #self.commSuite.user_quit() self.log.log_end("oraclessoLogin") u'''bs资源单点登录''' def bs_sso_login_002(self): #日志开始记录 self.log.log_start("BsssoLogin") #self.commSuite.sso_user_login(8) sso_data = self.get_table_data("database_sso") #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(sso_data)): data = sso_data[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow == 2 : self.database_common_func(data) except Exception as e: print ("Bs SSO login fail: ") + str(e) #self.commSuite.user_quit() self.log.log_end("BsssoLogin") u'''mysql资源单点登录''' def mysql_sso_login_003(self): #日志开始记录 self.log.log_start("mysqlssoLogin") #self.commSuite.sso_user_login(8) sso_data = self.get_table_data("database_sso") #无检查点的测试项标识,如果为True说明通过 flag = False for dataRow in range(len(sso_data)): data = sso_data[dataRow] try: #如果不是第一行标题,则读取数据 if dataRow == 3 : self.database_common_func(data) except Exception as e: print ("mysql SSO login fail: ") + str(e) #self.commSuite.user_quit() self.log.log_end("mysqlssoLogin")
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)