def test_apply_page(self): log_info(u"跳转到角色列表页面") role = System(self.driver) role.skip() role.get_text_obscure('角色管理').click() role.get_text_obscure('角色列表').click() log_info(u"查询最新的数据") sql = ''' select role_name,role_desc from (select * from t_role_info order by create_time desc ) aa where rownum =1 ''' db = Oracle() result = db.run_sql(sql) role_name = unicode(result[0], 'utf-8') role_desc = unicode(result[1], 'utf-8') role.input_text('用户角色', role_name) role.get_text_accurate('查询').click() #检查序号 role.assert2('1', role.row_check(1).text, u'序号') #检查用户角色 role.assert2(role_name, role.row_check(2).text, u'用户角色') #检查角色描述 role.assert2(role_desc, role.row_check(3).text, u'角色描述')
def check_database(self,sql): log_info(u"检查数据库") time.sleep(2) db = Oracle() result = db.run_sql(sql) db.disconnect() return result
def teat(): sql = '''SELECT t.ins_id AS insId, t.ins_name AS insName, d.channel_type AS channelType, d.channel_level_id, ( SELECT tcgi.ch_level_name FROM t_channel_grade_info tcgi WHERE tcgi.ch_grade_id = d.channel_level_id ) channelLevelName, c.corporate_name corporateName, d.create_by createBy, d.create_time createTime, d.channel_no AS channelNo, d.buy_card_limit buyCardLimit, d.try_card_limit tryCardLimit, d.recharge_count rechargeCount, d.channel_address AS channelAddress, d.longitude, d.latitude, d.region_code regionCode, d.attach_id attachId FROM t_channel_info d LEFT JOIN t_partner c ON d.partner_id = c.id INNER JOIN t_ins_info t ON d.ins_id = t.ins_id WHERE d.channel_no = '6302009999' ''' t = Oracle() kk = t.run_sql_dir(sql) print kk # for i in kk: i = list(kk[0]) print i print i[1]
def test_apply_page(self): log_info(u"跳转到角色列表页面") object = System(self.driver) object.skip() time.sleep(2) object.get_text_obscure('组织架构').click() time.sleep(2) object.get_element_by_xpath('//*[@id="app"]/div/div[1]/div/div/ul/li[2]/li/li[4]/ul/li/li/span').click() time.sleep(2) object.get_text_obscure('中福彩').click() time.sleep(2) #点击第一行的修改按钮 object.row_check(8).click() #生成唯一ID dep_id = str(object.create_id()) #部门负责人 user_name = u'部门负责人' + dep_id object.input_text('部门负责人',user_name) #负责人电话 user_mobile = u'13534075566' object.input_text('负责人电话',user_mobile) #备注 desc = u'备注' + dep_id object.input_text('备注',desc) #状态 try: #如果是关闭状态,点击关闭变成开启 object.get_text_accurate('关闭').click() except: #如果不是关闭状态,点击开启变成关闭 object.get_text_accurate('开启').click() object.get_text_obscure('提交并保存').click() #所以状态为0,关闭 status = 0 else: status = 1 object.get_text_obscure('提交并保存').click() #根据部门名称,查询数据库数据 sql = ''' select principal,principal_mobile,remark,status from T_DEPT_INFO where principal='%s' '''%user_name db = Oracle() result = db.run_sql(sql) #得到部门负责人 user_name = unicode(result[0], 'utf-8') #得到负责人电话 user_mobile = unicode(result[1], 'utf-8') #得到备注 desc = unicode(result[2], 'utf-8') #检查 object.assert2(result[0],user_name,u'部门负责人') object.assert2(result[1],user_mobile,u'负责人电话') object.assert2(result[2],desc,u'备注') object.assert2(result[3],status,u'状态')
def sql_LOB_result(self, sql): a = Oracle() tt = a.run_sql_LOB(sql) if len(tt) == 0: a = 0 return a else: return tt
def get_role_status(self, role_name): '''sql查询''' select_sql = u"select * from T_CHANNEL_ROLE_INFO where role_name='%s'" select = Oracle() data = select.run_sql(select_sql % role_name) if data[3] == u'1': return u'启用' elif data[3] == u'2': return u'冻结' elif data[3] == u'3': return u'注销' else: return u'状态位异常'
def test_apply_page(self): log_info(u"跳转到角色列表页面") object = System(self.driver) object.skip() time.sleep(2) object.get_text_obscure('组织架构').click() time.sleep(2) object.get_element_by_xpath( '//*[@id="app"]/div/div[1]/div/div/ul/li[2]/li/li[4]/ul/li/li/span' ).click() time.sleep(2) object.get_text_obscure('中福彩').click() object.get_text_obscure('添加部门').click() #生成唯一ID id = str(object.create_id()) dep_name = u'自动化测试部门' + id object.input_text('部门名称', dep_name) #部门负责人 user_name = u'部门负责人' + id object.input_text('部门负责人', user_name) #负责人电话 user_mobile = u'13534075566' object.input_text('负责人电话', user_mobile) #备注 desc = u'备注' + dep_name object.input_text('备注', desc) #状态 try: object.get_text_accurate('关闭').click() except: object.get_text_obscure('提交并保存').click() else: object.get_text_obscure('提交并保存').click() log_info(u"检查数据") sql = ''' select department_name,principal,principal_mobile,remark,status from T_DEPT_INFO where department_name='%s' ''' % dep_name db = Oracle() result = db.run_sql(sql) object.assert2(result[0], dep_name, u'部门名称') object.assert2(result[1], user_name, u'部门负责人') object.assert2(result[2], user_mobile, u'负责人电话') object.assert2(result[3], desc, u'备注') object.assert2(result[4], 1, u'状态')
def test_apply_page(self): log_info(u"跳转到页面") object = UserManager(self.driver) object.skip() object.get_text_obscure('新建用户').click() #生成唯一ID user_code = str(object.create_id()) user_name = u'自动化测试名字' + str(user_code) object.input_text('姓名',user_name) object.input_text('用户账号',user_name) user_mobile = object.create_mobile() object.input_text('手机号码',user_mobile) user_mail = u'*****@*****.**' object.input_text('邮箱',user_mail) object.get_element_by_xpath('//*[@id="app"]/div/div[2]/div[2]/div/div/div/div/form/div[5]/div/div/div[1]/input').click() object.click_radio('中福彩') object.get_text_obscure('所属部门').click() object.get_element_by_xpath('//*[@id="app"]/div/div[2]/div[2]/div/div/div/div/form/div[6]/div/div/div[1]/input').click() object.click_radio('自动化测试部门') object.get_text_obscure('用户角色').click() object.get_element_by_xpath('//*[@id="app"]/div/div[2]/div[2]/div/div/div/div/form/div[8]/div/div/div[2]/input').click() object.get_text_obscure('自动化测试角色').click() object.get_text_obscure('提交并保存').click() log_info(u"检查数据") sql = ''' select user_name,account,mobile,email,user_status,cc.ins_name from t_user_info aa left join t_user_ins bb on aa.user_id = bb.user_id left join t_ins_info cc on cc.ins_id = bb.ins_id where account='%s' '''%user_name db = Oracle() result = db.run_sql(sql) object.assert2(result[0],user_name,u'姓名') object.assert2(result[1],user_name,u'用户账号') object.assert2(result[2],user_mobile,u'手机号码') object.assert2(result[3],user_mail,u'邮箱') object.assert2(result[4],0,u'状态') object.assert2(result[5],u'中福彩',u'机构名称')
def querydetail(self, channel_no=''): '''查询详情中内容''' # tt=self.channel_data() if channel_no == '': tt = self.channel_data() else: tt = channel_no if int(tt) > 0: sql = '''SELECT t.ins_name AS insName, case WHEN d.channel_type=0 then '自营厅' WHEN d.channel_type=1 then '合作厅' else NULL END, ( SELECT tcgi.ch_level_name FROM t_channel_grade_info tcgi WHERE tcgi.ch_grade_id = d.channel_level_id ) channelLevelName,d.channel_no AS channelNo, case WHEN a.RUN_FIELD=0 then '自有' WHEN a.RUN_FIELD=1 then '租用' else NULL END,a.POINT_AREA, d.channel_address AS channelAddress, d.longitude, d.latitude, d.buy_card_limit buyCardLimit, d.try_card_limit tryCardLimit, d.recharge_count rechargeCount, d.CHANNEL_LIMIT FROM t_channel_info d LEFT JOIN t_partner c ON d.partner_id = c.id INNER JOIN t_ins_info t ON d.ins_id = t.ins_id LEFT JOIN T_FINANCE_INFO a on a.channel_id=d.channel_id WHERE d.channel_no = '%s' ''' % tt t = Oracle() kk = t.run_sql_dir(sql) log_info(kk) return kk else: a = 0 return a
def ins(self): '''根据登陆用户拿相应的组织机构''' time.sleep(3) name=self.get_element_by_xpath(user_name).text user_ins_sql = ''' SELECT t.ins_id from T_USER_INS t left join T_USER_INFO k on t.user_id=k.user_id where k.account='%s' '''%name kk=Oracle().run_sql_list(user_ins_sql) log_info(kk) print "kk=%s"%kk kk1=kk[0] log_info(kk1) return kk1
def test_apply_page(self): log_info(u"跳转到系统管理页面") object = System(self.driver) object.skip() object.get_text_list('数据字典') object.get_text_list('数据字典') object.get_text_obscure('新增字典').click() #生成唯一ID unique_id = str(object.create_id()) disc_name = u'字典名称' + unique_id object.get_element_by_xpath( '//*[@id="main"]/div/div/div[3]/div/div/div[2]/div/div/form/div[1]/div/div/input' ).send_keys(disc_name) #object.input_text('数据字典名称',disc_name) disc_key = u'字典键' + unique_id object.input_text('数据字典键', disc_key) disc_value = u'字典键值' + unique_id object.input_text('字典数据值', disc_value) disc_desc = u'描述' + unique_id object.input_text('描述', disc_desc) object.get_text_obscure('提交并保存').click() log_info(u"检查数据") sql = ''' select name,key,value,description,is_allow_delete from T_DICT_DATA where name='%s' ''' % disc_name db = Oracle() result = db.run_sql(sql) object.assert2(result[0], disc_name, u'字典名称') object.assert2(result[1], disc_key, u'字典键') object.assert2(result[2], disc_value, u'字典值') object.assert2(result[3], disc_desc, u'字典描述') object.assert2(result[4], 1, u'状态')
def querydetail(self, channel_no=''): '''查询新增中的东西''' sql = '''SELECT d.channel_no AS channelNo, case WHEN d.channel_type=0 then '自营厅' WHEN d.channel_type=1 then '合作厅' else NULL END as shuxing, ( SELECT tcgi.ch_level_name FROM t_channel_grade_info tcgi WHERE tcgi.ch_grade_id = d.channel_level_id ) channelLevel, case WHEN a.RUN_FIELD=0 then '自有' WHEN a.RUN_FIELD=1 then '租用' else NULL END as filed,a.POINT_AREA as area, d.buy_card_limit as buyCardLimit, d.try_card_limit as tryCardLimit, d.recharge_count as rechargeCount, d.CHANNEL_LIMIT as CHANNELLIMIT, d.longitude , d.latitude,d.channel_address AS channelAddress, f.account_name as accountname,f.SEX as sex, f.PHONE as phone, f.CHANNEL_IDENTITY as cardid ,f.AGE as age,f.ADDRESS as address FROM t_channel_info d LEFT JOIN t_partner c ON d.partner_id = c.id INNER JOIN t_ins_info t ON d.ins_id = t.ins_id LEFT JOIN T_FINANCE_INFO a on a.channel_id=d.channel_id left JOIN T_CHANNEL_FUND f on d.channel_id=f.channel_id WHERE d.channel_no ='%s' ''' % channel_no t = Oracle() kk = t.run_sql_dir(sql) log_info(kk) return kk
def queryresult(self): '''根据登陆用户查询渠道数据''' ins = self.ins() sql = '''SELECT count(*) FROM (SELECT TMP.*, ROWNUM ROW_ID FROM (SELECT aa.channel_no AS channelNo, aa.channel_type AS channelType, bb.ins_name AS insName, ee.ch_level_name AS channelLevelName, cc.account_name AS accountName, cc.phone AS phone, aa.create_time AS createTime FROM t_channel_info aa LEFT JOIN t_ins_info bb ON aa.ins_id = bb.ins_id LEFT JOIN t_channel_fund cc ON aa.channel_id = cc.channel_id LEFT JOIN t_channel_role_info dd ON cc.role_id = dd.id LEFT JOIN t_channel_grade_info ee ON aa.channel_level_id = ee.ch_grade_id WHERE dd.is_manager = 1 AND ( bb.ins_id = %s OR bb.PARENT_ID = %s ) AND aa.is_his_channel = 0 AND aa.STATUS = 2 AND bb.region_code IN ( bb.region_code - MOD ( bb.region_code, 10000 ), bb.region_code - MOD ( bb.region_code, 100 ), bb.region_code - MOD ( bb.region_code, 1 ), 1 ) ORDER BY aa.create_time DESC ) TMP )''' % (ins, ins) tt = Oracle() kk = tt.run_sql_dir(sql) kk1 = kk[0] # kk2 = list(kk1) return kk2
def test_apply_page(self): log_info(u"跳转到页面") object = System(self.driver) object.skip() time.sleep(2) object.get_text_obscure('组织架构').click() time.sleep(2) object.get_element_by_xpath( '//*[@id="app"]/div/div[1]/div/div/ul/li[2]/li/li[4]/ul/li/li/span' ).click() time.sleep(2) object.get_text_obscure('中福彩').click() object.get_text_obscure('新增').click() log_info(u"删除香港机构的数据") sql = ''' delete from T_INS_INFO where region_code=810000 ''' db = Oracle() result = db.sql_delete(sql) #生成唯一ID unique_id = str(object.create_id()) object.input_text('机构名称', u'香港') #机构编码 ins_id = unique_id object.option_text('请输入机构编码').send_keys(ins_id) #区域 object.option_text('请选择').click() object.get_text_obscure('香港特别行政区').click() #object.click_radio('香港特别行政区') #备注 desc = u'备注' + unique_id object.input_text('备注', desc) object.get_text_obscure('提交并保存').click() log_info(u"检查数据") sql = ''' select ins_name,ins_code,region_code,remark from T_INS_INFO where ins_code='%s' ''' % ins_id db = Oracle() result = db.run_sql(sql) object.assert2(result[0], u'香港', u'机构名称') object.assert2(result[1], ins_id, u'机构编码') object.assert2(result[2], 810000, u'地区编码') object.assert2(result[3], desc, u'备注')
def test_apply_page(self): log_info(u"跳转到角色列表页面") role = System(self.driver) role.skip() role.get_text_obscure('角色管理').click() role.get_text_obscure('角色列表').click() log_info(u"查询最新的数据") sql = ''' select role_name,role_desc,role_code from (select * from t_role_info order by create_time desc ) aa where rownum =1 ''' db = Oracle() result = db.run_sql(sql) role_name = unicode(result[0], 'utf-8') role_desc = unicode(result[1], 'utf-8') role_code = unicode(result[2], 'utf-8') role.input_text('用户角色', role_name) role.get_text_accurate('查询').click() try: role.get_text_accurate('启用').click() except: role.get_text_obscure('编缉').click() else: role.get_text_obscure('确定').click() role.get_text_obscure('编缉').click() #生成唯一ID role_code1 = str(role.create_id()) role_name = u'自动化测试角色' + str(role_code1) role.input_text('用户角色', role_name) role_desc = u'自动化测试角色描述' + str(role_code1) role.input_text('描述', role_desc) role.get_text_accurate('提交并保存').click() log_info(u"检查数据") sql = ''' select role_code,role_name,role_desc,status from t_role_info where role_code='%s' ''' % role_code db = Oracle() result = db.run_sql(sql) role.assert2(result[0], role_code, u'角色编码') role.assert2(result[1], role_name, u'角色名称') role.assert2(result[2], role_desc, u'角色描述') role.assert2(result[3], 0, u'角色状态')
def test_apply_page(self): log_info(u"跳转到页面") object = ServiceManage(self.driver) object.skip() object.get_text_obscure('游戏储备管理').click() object.get_text_obscure('游戏储备列表').click() time.sleep(2) object.get_text_obscure('新建游戏').click() #生成唯一ID unique_id = str(object.create_id()) #游戏名称 game_name = u'自动化游戏名字' + unique_id object.input_text('游戏名称', game_name) #游戏编码 game_code = unique_id object.input_text('游戏编码', game_code) #游戏类型 object.option_text('请选择游戏类型').click() object.get_text_obscure('奖组型').click() #游戏奖池 object.option_text('请选择游戏奖池').click() object.get_text_obscure('多奖池').click() #游戏简介 game_desc = u'游戏简介自动化' object.input_text('游戏简介', game_desc) #版权归属 game_version = u'自动化版权归属' object.input_text('版权归属', game_version) #开发商名称 developer_name = u'自动化开发商名称' object.input_text('开发商名称', developer_name) #联系人 person = u'自动化联系人' object.input_text('联系人', person) #手机号码 mobile = object.create_mobile() object.input_text('手机号码', mobile) #电子邮箱 email = u'*****@*****.**' object.input_text('电子邮箱', email) #传真电话 fax_phone = u'11223344' object.input_text('传真电话', fax_phone) #联系地址 address = u'2233445566' object.input_text('联系地址', address) object.get_text_obscure('下一步').click() #点击上传 object.get_text_obscure('上传游戏包').click() object.get_text_obscure('点击上传').click() object.upload_file( r"E:\genlot_vlt\static\install\game-logic-luckycards-1.0.0.jar") #游戏图标 time.sleep(10) object.get_element_by_xpath( '//*[@id="main"]/div/div/div[3]/div/form/div[2]/div/div/div[1]/i' ).click() #object.input_text_click('游戏图标') object.upload_file(r"E:\genlot_vlt\static\images\test.png") #软件名称 object.input_text('软件名称', u'多福多宝') #版本名称 object.input_text('版本名称', u'V1.0.0') #版本号 object.input_text('版本号', u'100') #软件描述 object.input_text('软件描述', unique_id) #新版特性 object.input_text('新版特性', unique_id) object.get_text_list('下一步') object.get_text_obscure('提 交').click() #创建字典 game_tpye = {u'奖组型': 1, u'概率型': 2} jackpot_type = {u'无奖池': 1, u'单奖池': 2, u'多奖池': 3} log_info(u"检查数据") sql = ''' select game_name,game_code,game_type,jackpot_type,game_desc,game_genlot,bb.developer_name,bb.person,bb.cell_phone,bb.email,bb.fax_phone,bb.address from T_GAME_INFO aa left join T_DEVELOPER_INFO bb on bb.id = aa.developer_id where aa.game_code ='%s' ''' % game_code db = Oracle() result = db.run_sql(sql) object.assert2(result[0], game_name, u'游戏名称') object.assert2(result[1], game_code, u'游戏编码') object.assert2(result[2], game_tpye[u'奖组型'], u'游戏类型') object.assert2(result[3], jackpot_type[u'多奖池'], u'游戏奖池') object.assert2(result[4], game_desc, u'游戏简介') object.assert2(result[5], game_version, u'版权归属') object.assert2(result[6], developer_name, u'开发商名称') object.assert2(result[7], person, u'联系人') object.assert2(result[8], mobile, u'手机号码') object.assert2(result[9], email, u'电子邮箱') object.assert2(result[10], fax_phone, u'传真电话') object.assert2(result[11], address, u'联系地址')
def test_apply_page(self): log_info(u"跳转到页面") object = ServiceManage(self.driver) object.skip() time.sleep(2) object.get_text_obscure('渠道业务管理').click() object.get_text_obscure('年度发展计划').click() log_info(u"删除新疆机构的当前年的数据") year = time.strftime('%Y', time.localtime(time.time())) sql = ''' delete from T_DEVELOP_PLAN where plan_date = '%s' and ins_id = (select ins_id from t_ins_info where ins_name like '%s' ) ''' % (year, '新疆%') db = Oracle() result = db.sql_delete(sql) object.get_text_obscure('新建发展计划').click() time.sleep(2) object.option_text('请选择所属机构').click() object.click_radio('新疆') #生成唯一ID unique_id = str(object.create_id()) #省属新建销售厅数量 province_sales_hall_new = unique_id object.input_text('省属新建销售厅数量', province_sales_hall_new) #省属销售厅投注机数量 province_sales_machine_new = 20 object.input_text('省属销售厅投注机数量', province_sales_machine_new) #省合作厅数量 province_cooperate_amount = 30 object.input_text('省合作厅数量', province_cooperate_amount) #省合作厅投注机数量 province_cooperate_machine_amount = 40 object.input_text('省合作厅投注机数量', province_cooperate_machine_amount) #发展预算金额 develop_buget = 100 object.input_text('发展预算金额', develop_buget) #计划说明 plan_desc = u'说明' object.input_text('计划说明', plan_desc) object.get_text_obscure('提交并保存').click() log_info(u"检查数据") sql = ''' select aa.NEW_SELLING_HALL , SELLING_MACHINE ,COOPERATION_HALL,COOPERATION_MACHINE,aa.DEVELOP_BUDGET,aa.plan_desc from T_DEVELOP_PLAN aa left join t_ins_info bb on aa.ins_id = bb.ins_id where aa.ins_level = 1 and aa.plan_date = '%s' ''' % year db = Oracle() result = db.run_sql(sql) object.assert2(result[0], int(province_sales_hall_new), u'省属新建销售厅数量') object.assert2(result[1], province_sales_machine_new, u'省属销售厅投注机数量') object.assert2(result[2], province_cooperate_amount, u'省合作厅数量') object.assert2(result[3], province_cooperate_machine_amount, u'省合作厅投注机数量') object.assert2(result[4], develop_buget * 100, u'发展预算金额') object.assert2(result[5], plan_desc, u'计划说明')
def get_column_value(self,sql): '''从数据库查询列值''' select=Oracle() result=select.run_sql(sql) return result
def get_data_count(self,select_sql): '''从数据库查询条数''' select=Oracle() result=select.get_data(select_sql) return len(result)