def login(): print('songshu ----------- login') p.sessionstart() global c global s c = wda.Client() s = c.session() s.set_alert_callback(_alert_callback) ss = s(name='立即登录').exists i = 0 while not ss and i < 10: ss = s(name='立即登录').exists print('查找是否有sdk登录:%d' % i) i += 1 sleep(3) if ss: s(name='立即登录').get(3).click() sleep(3) sb = s(name='稍后绑定').exists if sb: s(name='稍后绑定').get(3).click() sleep(2) #SDK信息 p.report('login','调用游戏登录', 'start') p.game('autologin') p.report('login','调用游戏登录', 'end') return
def login(): print('yanwan --------- login') p.report('login', '调用sdk登录', 'start') p.sessionstart() global c global s c = wda.Client() s = c.session() ss = s(name='进入游戏').exists sleep(3) i = 0 while not ss and i < 5: ss = s(name='进入游戏').exists i += 1 sleep(2) if ss: s(name='进入游戏').get(3).click() p.report('', '进入游戏', '') sleep(2) sleep(3) #SDK信息 p.report('', '调用游戏登录', 'start') p.game('autologin') p.report('', '调用游戏登录', 'end') p.report('', '登录', 'end') return
def autologin(): p.report('', '游戏登录', 'start') global c global s c = wda.Client() s = c.session() sleep(3) click_picture(p.shot(), '/Volumes/ntfs3/ios_python/jzx/kaishiyouxi.png', '开始游戏') newj = find_picture(p.shot(), '/Volumes/ntfs3/ios_python/jzx/jinruyouxi.png', '进入游戏') if newj: click_picture(p.shot(), '/Volumes/ntfs3/ios_python/jzx/jinruyouxi.png', '进入游戏') game = not find_picture( p.shot(), '/Volumes/ntfs3/ios_python/jzx/chongzhi.png', '游戏界面') i = 0 while game and i < 3: s.tap(330, 50) i += 1 game = not find_picture( p.shot(), '/Volumes/ntfs3/ios_python/jzx/chongzhi.png', '游戏界面') if not game: p.report('', '登录游戏', 'tcend') sleep(5) p.shot()
def update(): sleep(3) # if click_picture(ima,'login.png','') p.report('', '启动游戏更新', 'start') p.game('update') p.report('', '启动游戏更新', 'tcend') sleep(3)
def get_all_app(): '''获取手机上所有的APP信息''' pp= Popen('ideviceinstaller -l',shell=True,stdout=PIPE,stderr=PIPE) p.report('','获取设备应用信息','') out,err = pp.communicate() out += err sleep(3) return out.decode()
def apple_pay(s, userid, userpwd): print('ps----------------------apple_pay') s.set_alert_callback(_alert_callback) print('apple_pay being') id_wait = s(name='使用现有的 Apple ID') i = 0 while not id_wait.exists: sleep(5) id_wait = s(name='使用现有的 Apple ID') i += 1 print('第%d次寻找是否弹出了账号输入' % i) p.report('', '', '第%d次寻找是否弹出了账号输入' % i) if i == 15: #没有找到账号输入,证明需要重新点击 return False #输入账号密码 if id_wait.exists: id_wait.get(5).click() sleep(4) e = s(value='*****@*****.**') if e.exists: e.get(timeout=5).set_text(userid) s(value='密码').get(timeout=3).set_text(userpwd) p.shot() s(name='购买').get(timeout=3).tap() buy_wait = s(name='购买') #确认购买 i = 0 while not buy_wait.exists: sleep(5) buy_wait = s(name='购买') i += 1 print('第%d次寻找是否弹出了购买确认' % i) p.report('', '', '第%d次寻找是否弹出了购买确认' % i) if i == 15: #确认购买框还没有出来,重新购买 return False if buy_wait.exists: sleep(3) p.shot() buy_wait.get(5).click() sleep(3) sure_wait = s(name='好') i = 0 while not sure_wait.exists and i < 15: sleep(5) sure_wait = s(name='好') i += 1 print('第%d次寻找是否弹出了购买完毕' % i) if sure_wait.exists: p.shot() sure_wait.get(5).click() return True
def install_app(bundle_id_addredss,ud_id): '''安装APP''' print('开始安装----') p.report('','','开始安装') cml = 'ideviceinstaller -u ' + ud_id + ' -i ' + bundle_id_addredss pp= Popen(cml, shell=True, stdout=PIPE, stderr=PIPE) out, err = pp.communicate() out += err sleep(15) return out.decode()
def uninstall_app(bundle_id,ud_id): '''卸载APP''' cml = 'ideviceinstaller -u ' + ud_id + ' -U ' + bundle_id print(cml) pp= Popen(cml, shell=True, stdout=PIPE, stderr=PIPE) out,err = pp.communicate() out += err print('已经安装过,开始卸载') p.report('','检测到已经安装过','已经安装过,开始卸载') return out.decode()
def update(): p.report('', 'sdk游戏更新', 'start') print(p.task_id) p.report1('', 'update', '截图') sleep(5) aa = p.shot() if click_picture(aa, '/Users/lichun/Documents/lihui/bingxue/allow.png', '查询是否要允许'): p.report('', '允许发送通知', 'update') sleep(3)
def login(): #出现权限允许 if click_picture(p.shot(), '/Users/lichun/Documents/lihui/bingxue/allow.png', '查询是否要允许'): p.report('', '允许发送通知', 'update') #SDK信息 report('调用游戏登录', 'start') p.game('login') report('调用游戏登录', 'end') p.report('', '登录', 'tcend') return
def zhuce(): print('songshu --------- zhuce') global c global s c = wda.Client() s = c.session() s.set_alert_callback(_alert_callback) ss = s(name='SS register').exists i = 0 while not ss and i < 10: ss = s(name='SS register').exists i += 1 sleep(3) if ss: s(name='SS register').get(3).click() sleep(2) allz = 'abcdefghijklmnopqrstuvwxyz' allzlist = list(allz) username = random.sample(allzlist, 9) s(name='一键注册').get(3).click() sleep(2) s(name='SS close').get(3).click() i += 1 p.report('zhuce', '游戏注册', 'end') #进入游戏 #login() p.report('', '调用游戏登录', 'start') p.game('login') p.report('', '调用游戏登录', 'end') p.report('', '登录', 'tcend') return
def update(): p.report('update', '更新', 'start') global s global c #s = p.sessionstart() # s.set_alert_callback(_alert_callback) sleep(2) # 查找权限允许 i = 0 while i < 5: allow = s(name='允许').exists if allow: s(name='允许').get(timeout=3).click() p.shot() allow = s(name='好').exists if allow: s(name='好').get(timeout=3).click() p.shot() allow = s(name='确定').exists if allow: s(name='确定').get(timeout=3).click() p.shot() i += 1 sleep(3) p.report('', '权限允许查询', '第%d次' % i) el = click_picture(p.shot(), '/Volumes/ntfs3/ios_python/jzx/shantui.png', '闪退,我知道了') # print(a) if el: p.report('', '优化闪退', '退出重进') p.sessionstart() nel = not el i = 0 while nel and i < 2: el = click_picture(p.shot(), '/Volumes/ntfs3/ios_python/jzx/shantui.png', '闪退,我知道了') if el: p.report('', '优化闪退', '退出重进') p.sessionstart() nel = not el sleep(3) p.report('', '查找闪退图', '第%d次' % i) i += 1
def replace_server(newT, baginT): global c global s c = wda.Client() s = c.session() if not newT and not baginT: #没有进入游戏,服务器有问题,更换服务器 if click_picture( p.shot(), '/Users/lichun/Documents/lihui/bingxue/sever_replace.png', '更换服务器'): if click_picture( p.shot(), '/Users/lichun/Documents/lihui/bingxue/sever_new.png', '点击新服'): pass else: print('没有服务器') p.report('', '', '没有服务器')
def pay(): p.checkweb1() p.report('pay', 'pay', 'start') p.report('', '测试六元档', 'start') p.game('pay') p.report('', '测试六元档', 'end') sleep(5) #p.checkweb() p.report('', '订单', 'end') return
def pay(): global c global s c = wda.Client() s = c.session() p.checkweb1() p.report('pay', 'pay', 'start') p.report('', '测试六元档', 'start') p.game('pay') p.report('', '测试六元档', 'end') sleep(5) #p.checkweb() p.report('', '订单', 'end') return
def find_picture(screen_picture, current_picture, thing): global c global s c = wda.Client() s = c.session() p1 = screen_picture p2 = current_picture a, x, y = opencv.imgcompare(p1, p2) k = 0 while not a: c.screenshot(screen_picture) p1 = screen_picture p2 = current_picture a, x, y = opencv.imgcompare(p1, p2) k = k + 1 # 隔二秒再截图 sleep(2) p.report('', thing, i) if k == 4: return False if a: print('找图 获取点击坐标', thing, a, x, y) return True
def jing_zhuce(): print('jzx --- zhuce') #p.report('zhuce', '快速注册账号', 'start') global c global s c = wda.Client() s = c.session('qmgjxy.cyhd') ss = s(name='快速注册').exists i = 0 while not ss and i < 10: ss = s(name='快速注册').exists i += 1 sleep(3) if ss: s(name='快速注册').get(3).click() sleep(2) ss = s(name='注册').exists i = 0 while not ss and i < 10: ss = s(name='注册').exists i += 1 sleep(3) if ss: s(name='注册').get(3).click() p.report('', '快速注册账号', 'tcend') sleep(2) else: # 如果没有找到注册按钮,证明没有进入快速注册界面,注册失败 #p.report('', '快速注册账号', 'fail') return #p.report('', '游戏快速注册', 'end') print('jzx --- zhuce') return
def zhuce(): global c global s c = wda.Client() s = c.session() p.report('zhuce', '', '注册新账号') if click_picture(p.shot(), '/Users/lichun/Documents/lihui/bingxue/register.png', '自定义注册账号'): p.report('zhuce', '注册新账号', '') if click_picture(p.shot(), '/Users/lichun/Documents/lihui/bingxue/user.png', '输入账号'): allz = 'abcdefghijklmnopqrstuvwxyz' allzlist = list(allz) username = random.sample(allzlist, 9) s(name='L').get(timeout=3).tap() for a in username: s(name=a).get(timeout=3).tap() p.report('zhuce', '账号', ''.join(username)) p.report('zhuce', '密码', 'qqqqqqq') s(name='Next:').get(timeout=4).tap() #密码7个q for i in range(7): s(name='q').get(timeout=3).tap() s(name='Next:').get(timeout=4).tap() #确认密码 for i in range(7): s(name='q').get(timeout=3).tap() s(name='Done').get(timeout=4).tap() sleep(1) if click_picture( p.shot(), '/Users/lichun/Documents/lihui/bingxue/register_success.png', '输入账号信息准备进入游戏'): print('success') #绑定手机号 if click_picture( p.shot(), '/Users/lichun/Documents/lihui/bingxue/after.png', '稍后绑定'): print('准备进入游戏') report('绑定手机号', '取消') else: report('没有找到绑定手机号界面', '') #进入游戏 login() return
def shiyuan(): global c global s c = wda.Client() s = c.session() p.report('shiyuan', 'shiyuan', 'start') p.report('', '调用游戏充值', 'start') p.game('shiyuan') p.report('', '调用游戏充值', 'end') sleep(5) #等待是否出现APPle输入账号界面,相当于判断是否会进入到订单界面 find_picture(p.shot(), '/Users/lichun/Documents/lihui/jzx/buysure.png', '确认购买') dot = 0 while not e.exists: dot += 1 if dot > 10: p.report('', '等待订单出现界面超时', 'fail') report() sleep(5) p.report('', '等待订单界面出现', '等待中') e = s(name='使用现有的 Apple ID')
def pay(): global c global s c = wda.Client() s = c.session() p.report('pay', 'pay', 'start') p.report('', '测试六元档', 'start') p.game('pay') p.report('', '测试六元档', 'end') sleep(5)
def pay2(): print('jzx---------------------pay') #打开首充界面 p.report('', '游戏6元', 'start') #sleep(2) s.tap(330, 50) #防止触发任务,在游戏中上方点击下 i = 0 while not find_picture(p.shot(), '/Volumes/ntfs3/ios_python/jzx/chongzhi.png', '打开充值界面') and i < 4: p.report('', '', '点击一下屏幕') s.tap(330, 50) i += 1 sleep(1) sleep(1) s.tap(330, 50) #正常支付流程 打开充值-点击6元档-支付 if click_picture(p.shot(), '/Volumes/ntfs3/ios_python/jzx/chongzhi.png', '打开充值界面'): #p.report('','游戏主界面','打开充值界面') i = 0 while click_picture(p.shot(), '/Volumes/ntfs3/ios_python/jzx/jzx_six.png', '点击六元档') and i < 3: p.report('', '充值界面', '打开六元充值档') #apple支付判断界面 user = '******' pwd = 'Dongxiao123' pay_end = ps.apple_pay(c.session(), user, pwd) if pay_end == True: print('支付成功') p.report('pay', '游戏6元', 'end') break elif pay_end == 2: print('需要重新点击6元档') elif pay_end == 3: #输入账号密码之后,如果超时,1、等待超时,重新购买 2、沙箱账号问题 print('等待确认输入框超时,重新购买') else: print('其它情况') i += 1
def login(): print('dalan ----------- login') sleep(3) p.sessionstart() p.report('login', 'sdk登录', 'start') global c global s c = wda.Client() s = c.session() #s.set_alert_callback(_alert_callback) sleep(5) #SDK信息 p.report('login', '调用游戏登录', 'start') p.game('autologin') p.report('login', '调用游戏登录', 'end') p.report('', '登录', 'end') return
def zhuce(): print('songshu --------- zhuce') global c global s c = wda.Client() s = c.session() ss = s(name='游客登录').exists i = 0 while not ss and i < 10: ss = s(name='游客登录').exists i += 1 sleep(3) if ss: s(name='游客登录').get(3).click() sleep(2) s(name='SS register protocol nomal@2x').get(3).click() sleep(2) s(name='游客登录').get(3).click() i += 1 sleep(4) # 出现权限,不允许 allow = s(name='不允许').exists if allow: s(name='不允许').get(timeout=3).click() sleep(2) close = s(name='SS close').exists if close: s(name='SS close').get(timeout=3).click() sleep(2) p.report('zhuce','游戏注册','end') #进入游戏 #login() p.report('','调用游戏登录','start') p.game('login') p.report('', '调用游戏登录', 'end') return
def zhuce(): print('yaowan --------- zhuce') p.report('zhuce', 'sdk注册', 'start') global c global s c = wda.Client() s = c.session() p.shot() #点击要玩的忘记密码,再回到主界面 ss = s(name='忘记密码').exists i = 0 while not ss and i < 5: ss = s(name='忘记密码').exists i += 1 sleep(2) if ss: s(name='忘记密码').get(3).click() sleep(2) p.shot() ss = s(name='返回').exists i = 0 while not ss and i < 5: ss = s(name='返回').exists i += 1 sleep(2) if ss: s(name='返回').get(3).click() sleep(2) report('', '返回密码正常,已经回到界面') ss = s(name='戻る').exists i = 0 while not ss and i < 5: ss = s(name='戻る').exists i += 1 sleep(2) if ss: s(name='戻る').get(3).click() sleep(2) report('', '返回密码正常,已经回到界面') else: print('没有看到忘记密码') report('', '没有看到忘记密码按钮,或者没有找到') #快速注册 ss = s(name='快速注册').exists i = 0 while not ss and i < 5: ss = s(name='快速注册').exists i += 1 sleep(2) if ss: s(name='快速注册').get(3).click() sleep(2) #允许保存到相册中 ss = s(name='好').exists i = 0 while not ss and i < 5: ss = s(name='好').exists i += 1 sleep(1) if ss: s(name='好').get(3).click() sleep(2) ss = s(name='好的').exists i = 0 while not ss and i < 5: ss = s(name='好的').exists i += 1 sleep(1) if ss: s(name='好的').get(3).click() sleep(2) sleep(3) #进入游戏 #login() p.report('', '调用游戏登录', 'start') p.game('login') p.report('', '调用游戏登录', 'end') return
def zhuce_my(): print('zhangkun --------- zhuce') p.report('zhuce_my', '开始', '') p.sessionstart() global c global s global username c = wda.Client() s = c.session() s.set_alert_callback(_alert_callback) ss = s(name='账号注册').exists p.report('', '首次查找账号注册', '') sleep(2) i = 0 while not ss and i < 5: ss = s(name='账号注册').exists i += 1 sleep(2) if ss: p.report('', '点击账号注册', '') s(name='账号注册').get(3).click() sleep(2) sleep(3) # 输入账号 user = s(className='TextField', value='6-20位数字或字母').exists if user: print('user') allz = 'abcdefghijklmnopqrstuvwxyz123456789abcdefghijklmnopqrstuvwxyz123456789' allzlist = list(allz) username = random.sample(allzlist, 12) user_ku = '' for a in username: user_ku = user_ku + a print(user_ku) s(className='TextField', value='6-20位数字或字母').set_text(username) p.report('', '账号注册账号', user_ku) p.report('zhuce_my', '立即注册', '') sleep(3) s(name='隐藏键盘').get(timeout=3).click() sleep(2) p.report('', '隐藏账号键盘', '') pwd = s(className='TextField', value='6-20位数字或字母').exists if pwd: print('pwd') s(className='TextField', value='6-20位数字或字母').set_text('110110') p.report('', '点击账号密码', '110110') sleep(1) s(name='隐藏键盘').get(timeout=3).click() sleep(2) p.report('', '隐藏密码键盘', '') sleep(1) ss = s(name='立即注册').exists sleep(2) i = 0 while not ss and i < 5: ss = s(name='立即注册').exists i += 1 p.report('', '查找立即注册按钮', i) sleep(2) if ss: p.shot() sleep(2) s(name='立即注册').get(3).click() p.report('', '注册账号成功', '') sleep(2) sleep(3) ss = s(name='close button').exists sleep(2) i = 0 while not ss and i < 5: ss = s(name='close button').exists i += 1 sleep(2) if ss: s(name='close button').get(3).click() sleep(2) sleep(3) #进入游戏 #login() p.report('', '调用游戏登录', 'start') p.game('login') p.report('', '调用游戏登录', 'end') return
def zhuce(): print('zhangkun --------- zhuce') p.report('zhuce', '掌昆游戏注册', 'start') global c global s c = wda.Client() s = c.session() ss = s(name='立即注册').exists i = 0 while not ss and i < 5: ss = s(name='立即注册').exists p.report('', '查找注册接口', i) i += 1 sleep(2) if ss: s(name='立即注册').get(3).click() p.report('zhuce', '立即注册', '') sleep(2) sleep(3) ss = s(name='好').exists i = 0 while not ss and i < 5: ss = s(name='好').exists i += 1 sleep(2) if ss: s(name='好').get(3).click() p.report('zhuce', '好', '') sleep(2) sleep(3) ss = s(name='close button').exists i = 0 while not ss and i < 5: ss = s(name='close button').exists i += 1 sleep(2) if ss: s(name='close button').get(3).click() p.report('zhuce', '关掉手机绑定', '') sleep(2) sleep(3) #进入游戏 #login() p.report('', '调用游戏登录', 'start') p.game('login') s.close() p.report('', '调用游戏登录', 'end') return
def update(): p.report('update','更新','start') print(p.task_id) global s global c s = p.sessionstart() #s.set_alert_callback(_alert_callback) if s == '': p.report('','游戏启动失败','fail') sleep(2) #查找权限允许 i = 0 while i < 5: allow = s(name='允许').exists if allow: s(name='允许').get(timeout=3).click() p.shot() allow = s(name='好').exists if allow: s(name='好').get(timeout=3).click() p.shot() allow = s(name='确定').exists if allow: s(name='确定').get(timeout=3).click() p.shot() i += 1 sleep(3) p.report('','权限允许查询','第%d次' % i ) el = click_picture(p.shot(), '/Volumes/ntfs3/ios_python/jzx/shantui.png', '闪退,我知道了') # print(a) if el: p.report('','优化闪退','退出重进') nel = not el i = 0 while nel and i < 2: el = click_picture(p.shot(), '/Volumes/ntfs3/ios_python/jzx/shantui.png', '闪退,我知道了') if el: p.report('', '优化闪退', '退出重进') nel = not el sleep(3) p.report('','查找闪退图','第%d次' % i) i += 1 p.sessionstart() sleep(3) # if click_picture(ima,'login.png','') p.report('','启动游戏更新','start') p.game('update') p.report('','启动游戏更新','tcend') p.tcfenxi() sleep(3)
def report(mo, msg): p.report('', mo, msg)
def zhuce(): print('jzx --- zhuce') p.report('zhuce', '快速注册账号', 'start') global c global s c = wda.Client() s = c.session() ss = s(name='快速注册').exists i = 0 while not ss and i < 10: ss = s(name='快速注册').exists i += 1 sleep(3) if ss: s(name='快速注册').get(3).click() sleep(2) ss = s(name='注册').exists i = 0 while not ss and i < 10: ss = s(name='注册').exists i += 1 sleep(3) if ss: s(name='注册').get(3).click() p.report('', '快速注册账号', 'tcend') sleep(2) else: #如果没有找到注册按钮,证明没有进入快速注册界面,注册失败 p.report('', '快速注册账号', 'fail') return p.report('', '游戏快速注册', 'end') #进入游戏 #login() p.report('', '调用游戏登录', 'start') p.game('login') p.report('', '调用游戏登录', 'end') return
def login(): print('zhangkun --------- zhuce') p.report('login', '调用sdk登录', 'start') p.sessionstart() global c global s c = wda.Client() s = c.session() ss = s(name='账号登录').exists sleep(3) i = 0 while not ss and i < 5: ss = s(name='账号登录').exists i += 1 sleep(2) if ss: s(name='账号登录').get(3).click() p.report('', '点击账号登录', '') sleep(2) sleep(3) # 输入账号 user = s(className='TextField', value='输入帐号/手机号').exists if user: #username='******' s(className='TextField', value='输入帐号/手机号').set_text(username) p.report('', '输入账号', '') sleep(3) s(name='隐藏键盘').get(timeout=3).click() pwd = s(className='TextField', value='输入密码').exists if pwd: print('pwd') s(className='TextField', value='输入密码').set_text('110110') p.report('', '输入密码', '') sleep(1) s(name='隐藏键盘').get(timeout=3).click() ss = s(name='进入游戏').exists sleep(3) i = 0 while not ss and i < 5: ss = s(name='进入游戏').exists i += 1 sleep(2) if ss: p.shot() s(name='进入游戏').get(3).click() sleep(2) p.report('', '进入游戏', '') sleep(3) ss = s(name='close button').exists i = 0 while not ss and i < 5: ss = s(name='close button').exists i += 1 sleep(2) if ss: s(name='close button').get(3).click() sleep(2) sleep(3) #SDK信息 p.report('', '调用游戏登录', 'start') p.game('autologin') p.report('', '调用游戏登录', 'end') p.report('', '登录', 'end') return