def click_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 print('尝试第', k, '次', thing) if k == 3: sleep(2) return False if a: print('截图 获取点击坐标', thing, a, x, y) p.touch(s, x, y) s.tap(x,y) return True
#! /usr/local/bin/python3 # -*- coding: UTF-8 -*- # 自动测试'融托金融'脚本编写 import atx import time import wda client = wda.Client() def main(): with client.session('com.ios.rongtuo') as s: # 登录 if s(name=u'登陆其他账户').exists: # 如果存在,切换账户 s(name=u'登陆其他账户').tap() # 输入 用户名 和 密码,点击‘登录’ s(type='TextField').send_keys( '13691457296' + '\n') # .set_text('13691457296'+'\n') s(type='SecureTextField').set_text('123789' + '\n') s(name=u'登录').tap() # 0 1 5 8 if s(classname='Other'): s(classname='Other', index=0).tap() s(classname='Other', index=1).tap() s(classname='Other', index=5).tap() s(classname='Other', index=8).tap() else: # 点击 ‘我的’进行‘登录’ # if s(classname='TabBar').exists: s(className='Button', index=3, name='').tap() # 输入 用户名 和 密码,点击‘登录’
# default False # Enable debug will see http Request and Response # wda.DEBUG = True wda.DEBUG = False # default 60.0 seconds wda.HTTP_TIMEOUT = 60.0 # port port = 8100 if len(sys.argv) > 1: port = sys.argv[1] pass # build connection c = wda.Client('http://localhost:' + str(port)) # show status print(c.status()) # instance s = c.session() e = s(type='TextField') # const words = [ "123\n", "新浪\n", "mip\n", "秋葵的做法大全\n", "海草舞\n", "曼联\n", "阿森纳\n", "切尔西\n", "热刺\n", "曼城\n", "利物浦\n", "波尔图\n", "大巴黎\n", "巴塞罗那\n", "皇马\n", "拜仁\n", "al\n", "ak\n", "az\n", "ar\n", "ca\n", "co\n", "ct\n", "de\n", "fl\n", "ga\n", "hi\n", "id\n", "il\n" ]
# -*- coding: utf-8 -*- import wda import dream from time import sleep if __name__ == '__main__': dream.c = wda.Client() dream.s = dream.c.session() while (True): try: # dream.autoMoney(section=s, indexs=[2]) # sleep(2) # dream.autoUpdateBuilds(section=s, indexs=[3,4,5]) # sleep(2) dream.c.screenshot('./dream.png') # dream.exchange_build() if (dream.is_has_train()): print('--有火车--') dream.newAutoGetGoods(section=dream.s, indexs=[0, 1]) # dream.newAutoGetGoods(section=dream.s, indexs=[0]) else: print('--无火车--') sleep(0.5) except: continue
def macIosScreenImg(): import wda wda.Client().screenshot('pic.png')
# 按实际的角度来算,找到接近下一个 board 中心的坐标 这里的角度应该 # 是 30°,值应该是 tan 30°, math.sqrt(3) / 3 board_y = piece_y - abs(board_x - piece_x) * math.sqrt(3) / 3 if not all((board_x, board_y)): return 0, 0, 0, 0 return piece_x, piece_y, board_x, board_y ######### Which App to Use ########## App_List = ['DouYin', 'Wechat_Jump'] Use_App = 'DouYin' c = wda.Client(url='http://18.189.58.186:8100') s = c.session() if len(sys.argv) == 1: try: w = s.window_size()[0] h = s.window_size()[1] Follow_Sign_x = w / 1080 * 1050 Follow_Sign_y = h / 1920 * 920 except: w = 750 / 2 h = 1334 / 2 Follow_Sign_x = 730 / 2 Follow_Sign_y = 640 / 2 else: w = int(sys.argv[1])
def test_alert_wait(): c = wda.Client(__target) with c.session('com.apple.Preferences') as s: # start_time = time.time() assert s.alert.wait(20)
def test_alert(): c = wda.Client(__target) with c.session('com.apple.Health') as s: #print s.alert.text pass
# -*- coding: utf-8 -*- import wda import random from time import sleep import cv2 import numpy from wda import Session c: wda.Client = wda.Client(url='http://192.168.0.106:8100') s: Session = c.session() class Point: x = 0 y = 0 def __init__(self, x, y): self.x = x self.y = y def image(): img_path = './dream.png' image = cv2.imread(filename=img_path) return image_resized(image, 0.333) def image_resized(image: numpy.ndarray, scale: float): width = int(image.shape[1] * scale) height = int(image.shape[0] * scale)
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
def __init__(self): self.client = wda.Client('http://192.168.1.103:8100') self.sess = self.client.session()
# coding: utf-8 import wda c = wda.Client('http://172.68.81.44:8100') def test_swipe(): s = c.session('com.apple.Preferences') print s.window_size() x1, y1, x2, y2 = (200, 500, 200, 200) s.swipe(x1, y1, x2, y2, 500) if __name__ == '__main__': test_swipe()
#!/usr/bin/env python # -*- coding: utf-8 -*- from mongo import op from tqdm import tqdm import json from ast import literal_eval a='[{ "referenceTime": "2020-11-08 17:28:00","referenceType": "Product","referenceTypeId": "0","firstCategory": "12218","secondCategory": "13591","thirdCategory": "13592","replyCount": "0","replyCount2": "0","score": "5","status": "1","title": "","usefulVoteCount": "0","uselessVoteCount": "0","userImage": "storage.360buyimg.com/i.imageUpload/6a645f3533626539306234383833643931353132303539343330323331_sma.jpg","userImageUrl": "storage.360buyimg.com/i.imageUpload/6a645f3533626539306234383833643931353132303539343330323331_sma.jpg","viewCount": "0","orderId": "0","isReplyGrade": False,"uid": "0","nickname": "咿呀伊尔呦10","userClient": "2","images":[],"videos":[],"showOrderComment":{"id": "","guid": "","content": "","creationTime": "","isTop": "","referenceId": "","referenceType": "","referenceTypeId": "","firstCategory": "","secondCategory": "","thirdCategory": "","replyCount": "","replyCount2": "","score": "","status": "","usefulVoteCount": "","uselessVoteCount": "","viewCount": "","orderId": "","isReplyGrade": "","uid": "","userClient": "","isDeal": "","integral": "","userImgFlag": "","anonymousFlag": "","mobileVersion": "","recommend": "","userLevelColor": "","userClientShow": ""},"mergeOrderStatus": "","discussionId": "","productColor": "鲜菜猪肉王水饺 600g","productSize": "","imageCount": "","integral": "0","userImgFlag": "1","anonymousFlag": "0","userLevelName": "PLUS会员","plusAvailable": "201","productSales":[],"mobileVersion": "","recommend": "False","userLevelColor": "#e1a10a","isMobile": True,"userClientShow": "来自京东iPhone客户端"},{ "id": "14921593873","topped": "0","guid": "1dbdcf2fbb53612d30ff0455ede5b154","content": "质量非常好,非常满意,真的很喜欢,发货速度非常快,包装非常仔细、严实,物流态度很好,运送速度很快,很满意的一次购物。","creationTime": "2020-11-17 18:45:08","isTop": False,"referenceId": "100000007131","referenceImage": "jfs/t1/101558/3/4477/179934/5de6fdb9E872eb689/9dfa86e4960978ed.jpg","referenceName": "必品阁(bibigo)鲜菜猪肉王水饺 600g 24只装 饺子 早餐食材","referenceTime": "2020-11-01 21:55:33","referenceType": "Product","referenceTypeId": "0","firstCategory": "12218","secondCategory": "13591","thirdCategory": "13592","replyCount": "0","replyCount2": "0","score": "5","status": "1","title": "","usefulVoteCount": "0","uselessVoteCount": "0","userImage": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","userImageUrl": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","viewCount": "0","orderId": "0","isReplyGrade": False,"uid": "0","nickname": "y***y","userClient": "4","images":[],"videos":[],"showOrderComment":{"id": "","guid": "","content": "","creationTime": "","isTop": "","referenceId": "","referenceType": "","referenceTypeId": "","firstCategory": "","secondCategory": "","thirdCategory": "","replyCount": "","replyCount2": "","score": "","status": "","usefulVoteCount": "","uselessVoteCount": "","viewCount": "","orderId": "","isReplyGrade": "","uid": "","userClient": "","isDeal": "","integral": "","userImgFlag": "","anonymousFlag": "","mobileVersion": "","recommend": "","userLevelColor": "","userClientShow": ""},"mergeOrderStatus": "","discussionId": "","productColor": "鲜菜猪肉王水饺 600g","productSize": "","imageCount": "","integral": "0","userImgFlag": "0","anonymousFlag": "1","userLevelName": "PLUS会员","plusAvailable": "201","productSales":[],"mobileVersion": "","recommend": "False","userLevelColor": "#e1a10a","isMobile": True,"userClientShow": "来自京东Android客户端"},{ "id": "14921139295","topped": "0","guid": "66e1d62ae339122ca1f908daa751c27f","content": "东西不错,物流迅速,值得推荐","creationTime": "2020-11-17 17:28:30","isTop": False,"referenceId": "100000007131","referenceImage": "jfs/t1/101558/3/4477/179934/5de6fdb9E872eb689/9dfa86e4960978ed.jpg","referenceName": "必品阁(bibigo)鲜菜猪肉王水饺 600g 24只装 饺子 早餐食材","referenceTime": "2020-11-01 23:54:32","referenceType": "Product","referenceTypeId": "0","firstCategory": "12218","secondCategory": "13591","thirdCategory": "13592","replyCount": "0","replyCount2": "0","score": "5","status": "1","title": "","usefulVoteCount": "0","uselessVoteCount": "0","userImage": "storage.360buyimg.com/i.imageUpload/ccecbad3c1f7d4c631343234393339313136373634_sma.jpg","userImageUrl": "storage.360buyimg.com/i.imageUpload/ccecbad3c1f7d4c631343234393339313136373634_sma.jpg","viewCount": "0","orderId": "0","isReplyGrade": False,"uid": "0","nickname": "天***云","userClient": "4","images":[],"videos":[],"showOrderComment":{"id": "","guid": "","content": "","creationTime": "","isTop": "","referenceId": "","referenceType": "","referenceTypeId": "","firstCategory": "","secondCategory": "","thirdCategory": "","replyCount": "","replyCount2": "","score": "","status": "","usefulVoteCount": "","uselessVoteCount": "","viewCount": "","orderId": "","isReplyGrade": "","uid": "","userClient": "","isDeal": "","integral": "","userImgFlag": "","anonymousFlag": "","mobileVersion": "","recommend": "","userLevelColor": "","userClientShow": ""},"mergeOrderStatus": "","discussionId": "","productColor": "鲜菜猪肉王水饺 600g","productSize": "","imageCount": "","integral": "0","userImgFlag": "1","anonymousFlag": "0","userLevelName": "PLUS会员","plusAvailable": "201","productSales":[],"mobileVersion": "","recommend": "False","userLevelColor": "#e1a10a","isMobile": True,"userClientShow": "来自京东Android客户端"},{ "id": "14920964046","topped": "0","guid": "d90edaf0fcc5b16fcae3df142e40b612","content": "味美价廉,京东自营值得信赖\x26hellip\x3B\x26hellip\x3B","creationTime": "2020-11-17 17:00:23","isTop": False,"referenceId": "100000007131","referenceImage": "jfs/t1/101558/3/4477/179934/5de6fdb9E872eb689/9dfa86e4960978ed.jpg","referenceName": "必品阁(bibigo)鲜菜猪肉王水饺 600g 24只装 饺子 早餐食材","referenceTime": "2020-10-24 18:28:27","referenceType": "Product","referenceTypeId": "0","firstCategory": "12218","secondCategory": "13591","thirdCategory": "13592","replyCount": "0","replyCount2": "0","score": "5","status": "1","title": "","usefulVoteCount": "0","uselessVoteCount": "0","userImage": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","userImageUrl": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","viewCount": "0","orderId": "0","isReplyGrade": False,"uid": "0","nickname": "阿瑞锦HK","userClient": "2","images":[],"videos":[],"showOrderComment":{"id": "","guid": "","content": "","creationTime": "","isTop": "","referenceId": "","referenceType": "","referenceTypeId": "","firstCategory": "","secondCategory": "","thirdCategory": "","replyCount": "","replyCount2": "","score": "","status": "","usefulVoteCount": "","uselessVoteCount": "","viewCount": "","orderId": "","isReplyGrade": "","uid": "","userClient": "","isDeal": "","integral": "","userImgFlag": "","anonymousFlag": "","mobileVersion": "","recommend": "","userLevelColor": "","userClientShow": ""},"mergeOrderStatus": "","discussionId": "","productColor": "鲜菜猪肉王水饺 600g","productSize": "","imageCount": "","integral": "0","userImgFlag": "0","anonymousFlag": "0","userLevelName": "PLUS会员","plusAvailable": "201","productSales":[],"mobileVersion": "","recommend": "False","userLevelColor": "#e1a10a","isMobile": True,"userClientShow": "来自京东iPhone客户端"},{ "id": "14920923867","topped": "0","guid": "c60ca1d388a4700671546739e6275330","content": "必品阁这几种口味的水饺我几乎都买遍了!玉米猪肉馅香甜扎实,饺子皮柔韧嫩滑~个个大只饱满,可蒸可煮,都好吃!好煮饱腹口味好!京东每次派大额生鲜券我都买上几包做应急口粮~包装好,日期新,送到时冻得很好没化冻,新鲜!","creationTime": "2020-11-17 16:52:41","isTop": False,"referenceId": "100000007131","referenceImage": "jfs/t1/101558/3/4477/179934/5de6fdb9E872eb689/9dfa86e4960978ed.jpg","referenceName": "必品阁(bibigo)鲜菜猪肉王水饺 600g 24只装 饺子 早餐食材","referenceTime": "2020-11-11 01:52:28","referenceType": "Product","referenceTypeId": "0","firstCategory": "12218","secondCategory": "13591","thirdCategory": "13592","replyCount": "0","replyCount2": "0","score": "5","status": "1","title": "","usefulVoteCount": "0","uselessVoteCount": "0","userImage": "storage.360buyimg.com/i.imageUpload/6469776f68616f6c6531343132333837343337363734_sma.jpg","userImageUrl": "storage.360buyimg.com/i.imageUpload/6469776f68616f6c6531343132333837343337363734_sma.jpg","viewCount": "0","orderId": "0","isReplyGrade": False,"uid": "0","nickname": "-日久","userClient": "4","images":[],"videos":[],"showOrderComment":{"id": "","guid": "","content": "","creationTime": "","isTop": "","referenceId": "","referenceType": "","referenceTypeId": "","firstCategory": "","secondCategory": "","thirdCategory": "","replyCount": "","replyCount2": "","score": "","status": "","usefulVoteCount": "","uselessVoteCount": "","viewCount": "","orderId": "","isReplyGrade": "","uid": "","userClient": "","isDeal": "","integral": "","userImgFlag": "","anonymousFlag": "","mobileVersion": "","recommend": "","userLevelColor": "","userClientShow": ""},"mergeOrderStatus": "","discussionId": "","productColor": "鲜菜猪肉王水饺 600g","productSize": "","imageCount": "","integral": "0","userImgFlag": "1","anonymousFlag": "0","userLevelName": "PLUS会员","plusAvailable": "201","productSales":[],"mobileVersion": "","recommend": "False","userLevelColor": "#e1a10a","isMobile": True,"userClientShow": "来自京东Android客户端"},{ "id": "14920849157","topped": "0","guid": "af35c0a46b18c50c21d22dce86d547e0","content": "水饺不错,还会再买!","creationTime": "2020-11-17 16:39:58","isTop": False,"referenceId": "100000007131","referenceImage": "jfs/t1/101558/3/4477/179934/5de6fdb9E872eb689/9dfa86e4960978ed.jpg","referenceName": "必品阁(bibigo)鲜菜猪肉王水饺 600g 24只装 饺子 早餐食材","referenceTime": "2020-09-24 09:03:24","referenceType": "Product","referenceTypeId": "0","firstCategory": "12218","secondCategory": "13591","thirdCategory": "13592","replyCount": "0","replyCount2": "0","score": "5","status": "1","title": "","usefulVoteCount": "0","uselessVoteCount": "0","userImage": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","userImageUrl": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","viewCount": "0","orderId": "0","isReplyGrade": False,"uid": "0","nickname": "N***T","userClient": "2","images":[],"videos":[],"showOrderComment":{"id": "","guid": "","content": "","creationTime": "","isTop": "","referenceId": "","referenceType": "","referenceTypeId": "","firstCategory": "","secondCategory": "","thirdCategory": "","replyCount": "","replyCount2": "","score": "","status": "","usefulVoteCount": "","uselessVoteCount": "","viewCount": "","orderId": "","isReplyGrade": "","uid": "","userClient": "","isDeal": "","integral": "","userImgFlag": "","anonymousFlag": "","mobileVersion": "","recommend": "","userLevelColor": "","userClientShow": ""},"mergeOrderStatus": "","discussionId": "","productColor": "鲜菜猪肉王水饺 600g","productSize": "","imageCount": "","integral": "0","userImgFlag": "0","anonymousFlag": "1","userLevelName": "银牌会员","plusAvailable": "203","productSales":[],"mobileVersion": "","recommend": "False","userLevelColor": "#666666","isMobile": True,"userClientShow": "来自京东iPhone客户端"},{ "id": "14920771557","topped": "0","guid": "39985bf6f5e1cfaf45c8084bf688613c","content": "品质还可以,经常会回购。","creationTime": "2020-11-17 16:27:43","isTop": False,"referenceId": "100000007131","referenceImage": "jfs/t1/101558/3/4477/179934/5de6fdb9E872eb689/9dfa86e4960978ed.jpg","referenceName": "必品阁(bibigo)鲜菜猪肉王水饺 600g 24只装 饺子 早餐食材","referenceTime": "2020-11-11 23:59:49","referenceType": "Product","referenceTypeId": "0","firstCategory": "12218","secondCategory": "13591","thirdCategory": "13592","replyCount": "0","replyCount2": "0","score": "5","status": "1","title": "","usefulVoteCount": "0","uselessVoteCount": "0","userImage": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","userImageUrl": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","viewCount": "0","orderId": "0","isReplyGrade": False,"uid": "0","nickname": "小***兔","userClient": "4","images":[],"videos":[],"showOrderComment":{"id": "","guid": "","content": "","creationTime": "","isTop": "","referenceId": "","referenceType": "","referenceTypeId": "","firstCategory": "","secondCategory": "","thirdCategory": "","replyCount": "","replyCount2": "","score": "","status": "","usefulVoteCount": "","uselessVoteCount": "","viewCount": "","orderId": "","isReplyGrade": "","uid": "","userClient": "","isDeal": "","integral": "","userImgFlag": "","anonymousFlag": "","mobileVersion": "","recommend": "","userLevelColor": "","userClientShow": ""},"mergeOrderStatus": "","discussionId": "","productColor": "鲜菜猪肉王水饺 600g","productSize": "","imageCount": "","integral": "0","userImgFlag": "0","anonymousFlag": "1","userLevelName": "PLUS会员","plusAvailable": "201","productSales":[],"mobileVersion": "","recommend": "False","userLevelColor": "#e1a10a","isMobile": True,"userClientShow": "来自京东Android客户端"},{ "id": "14920714019","topped": "0","guid": "ffbe6422ccafd1c33d52c56de35c1874","content": "饺子挺大的,皮薄馅多,挺好吃的","creationTime": "2020-11-17 16:18:36","isTop": False,"referenceId": "100000007131","referenceImage": "jfs/t1/101558/3/4477/179934/5de6fdb9E872eb689/9dfa86e4960978ed.jpg","referenceName": "必品阁(bibigo)鲜菜猪肉王水饺 600g 24只装 饺子 早餐食材","referenceTime": "2020-09-24 10:37:30","referenceType": "Product","referenceTypeId": "0","firstCategory": "12218","secondCategory": "13591","thirdCategory": "13592","replyCount": "0","replyCount2": "0","score": "5","status": "1","title": "","usefulVoteCount": "0","uselessVoteCount": "0","userImage": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","userImageUrl": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","viewCount": "0","orderId": "0","isReplyGrade": False,"uid": "0","nickname": "jd_雨润风和","userClient": "0","images":[],"videos":[],"showOrderComment":{"id": "","guid": "","content": "","creationTime": "","isTop": "","referenceId": "","referenceType": "","referenceTypeId": "","firstCategory": "","secondCategory": "","thirdCategory": "","replyCount": "","replyCount2": "","score": "","status": "","usefulVoteCount": "","uselessVoteCount": "","viewCount": "","orderId": "","isReplyGrade": "","uid": "","userClient": "","isDeal": "","integral": "","userImgFlag": "","anonymousFlag": "","mobileVersion": "","recommend": "","userLevelColor": "","userClientShow": ""},"mergeOrderStatus": "","discussionId": "","productColor": "鲜菜猪肉王水饺 600g","productSize": "","imageCount": "","integral": "0","userImgFlag": "0","anonymousFlag": "0","userLevelName": "银牌会员","plusAvailable": "103","productSales":[],"mobileVersion": "","recommend": "False","userLevelColor": "#666666","isMobile": False,"userClientShow": ""},{ "id": "14920651470","topped": "0","guid": "7b7cece8df06cbe60a789b9d539404d5","content": "味道不错,多次购买好评","creationTime": "2020-11-17 16:07:42","isTop": False,"referenceId": "100000007131","referenceImage": "jfs/t1/101558/3/4477/179934/5de6fdb9E872eb689/9dfa86e4960978ed.jpg","referenceName": "必品阁(bibigo)鲜菜猪肉王水饺 600g 24只装 饺子 早餐食材","referenceTime": "2020-10-16 12:33:20","referenceType": "Product","referenceTypeId": "0","firstCategory": "12218","secondCategory": "13591","thirdCategory": "13592","replyCount": "0","replyCount2": "0","score": "5","status": "1","title": "","usefulVoteCount": "0","uselessVoteCount": "0","userImage": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","userImageUrl": "misc.360buyimg.com/user/myjd-2015/css/i/peisong.jpg","viewCount": "0","orderId": "0","isReplyGrade": False,"uid": "0","nickname": "f***d","userClient": "0","images":[],"videos":[],"showOrderComment":{"id": "","guid": "","content": "","creationTime": "","isTop": "","referenceId": "","referenceType": "","referenceTypeId": "","firstCategory": "","secondCategory": "","thirdCategory": "","replyCount": "","replyCount2": "","score": "","status": "","usefulVoteCount": "","uselessVoteCount": "","viewCount": "","orderId": "","isReplyGrade": "","uid": "","userClient": "","isDeal": "","integral": "","userImgFlag": "","anonymousFlag": "","mobileVersion": "","recommend": "","userLevelColor": "","userClientShow": ""},"mergeOrderStatus": "","discussionId": "","productColor": "鲜菜猪肉王水饺 600g","productSize": "","imageCount": "","integral": "0","userImgFlag": "0","anonymousFlag": "1","userLevelName": "PLUS会员","plusAvailable": "201","productSales":[],"mobileVersion": "","recommend": "False","userLevelColor": "#e1a10a","isMobile": False,"userClientShow": ""},{ "id": "14920582890","topped": "0","guid": "03235237bc11ca385ddf016f83e35893","content": "还不错","creationTime": "2020-11-17 15:57:08","isTop": False,"referenceId": "100000007131","referenceImage": "jfs/t1/101558/3/4477/179934/5de6fdb9E872eb689/9dfa86e4960978ed.jpg","referenceName": "必品阁(bibigo)鲜菜猪肉王水饺 600g 24只装 饺子 早餐食材","referenceTime": "2020-09-24 09:16:16","referenceType": "Product","referenceTypeId": "0","firstCategory": "12218","secondCategory": "13591","thirdCategory": "13592","replyCount": "0","replyCount2": "0","score": "5","status": "1","title": "","usefulVoteCount": "0","uselessVoteCount": "0","userImage": "storage.360buyimg.com/i.imageUpload/31333936313739363831335f7031353732393939323037333831_sma.jpg","userImageUrl": "storage.360buyimg.com/i.imageUpload/31333936313739363831335f7031353732393939323037333831_sma.jpg","viewCount": "0","orderId": "0","isReplyGrade": False,"uid": "0","nickname": "jd_天天天蓝","userClient": "4","images":[],"videos":[],"showOrderComment":{"id": "","guid": "","content": "","creationTime": "","isTop": "","referenceId": "","referenceType": "","referenceTypeId": "","firstCategory": "","secondCategory": "","thirdCategory": "","replyCount": "","replyCount2": "","score": "","status": "","usefulVoteCount": "","uselessVoteCount": "","viewCount": "","orderId": "","isReplyGrade": "","uid": "","userClient": "","isDeal": "","integral": "","userImgFlag": "","anonymousFlag": "","mobileVersion": "","recommend": "","userLevelColor": "","userClientShow": ""},"mergeOrderStatus": "","discussionId": "","productColor": "鲜菜猪肉王水饺 600g","productSize": "","imageCount": "","integral": "0","userImgFlag": "1","anonymousFlag": "0","userLevelName": "PLUS会员","plusAvailable": "201","productSales":[],"mobileVersion": "","recommend": "False","userLevelColor": "#e1a10a","isMobile": True,"userClientShow": "来自京东Android客户端"}]' print(a[5600:]) print(literal_eval(a)) with op.DBManger() as m: # 创建临时表本月任务的分界线 skuid_set = set() pipeline = [ { "$project": { "app_id": "$app_id", } }, ] for item in m.read_from_yield(db_collect=("jicheng", "autopkgcatpure"), out_field=("app_id",), pipeline=pipeline): pass import wda w = wda.Client("") s = w.session() s.close()
level=logging.INFO) logging.getLogger("requests").setLevel(logging.WARNING) # 屏幕分辨率 该分辨率是通过wda的inspector得到的。 # device_x, device_y = 1920, 1080 device_x, device_y = 667, 375 # 截图的分辨率 base_x, base_y = 667, 375 # 小号 60左右 da 30 FIGHT_TIME = 30 # 刷金币次数 repeat_times = 175 c = wda.Client('http://127.0.0.1:8100') s = c.session() # =============================== # 所有坐标轴都以 左上角为原点 # home键在左方 # 按钮:再次挑战 # (650,130) (710,310) rb_x1, rb_y1 = 520, 330 rb_x2, rb_y2 = 610, 360 # 返回按钮 return_x1, return_y1 = 410, 330 return_x2, return_y2 = 505, 365
import sys import subprocess import time import random from PIL import Image import torch import torch.nn as nn import torchvision.transforms as transforms from torch.autograd import Variable import wda SCALE = 0.93 client = wda.Client("http://169.254.105.154:8100") session = client.session() def pull_screenshot(name="autojump.png"): client.screenshot(name) class CNNEncoder(nn.Module): """docstring for ClassName""" def __init__(self): super(CNNEncoder, self).__init__() self.layer1 = nn.Sequential( nn.Conv2d(3, 64, kernel_size=3, padding=0), nn.BatchNorm2d(64, momentum=1, affine=True), nn.ReLU(), nn.MaxPool2d(2))
def test_status(): c = wda.Client(__target) print c.status() c.screenshot()
def test_scroll(): c = wda.Client(__target) with c.session('com.apple.Preferences') as s: s(class_name='Table').scroll('Developer') s(text='Developer').tap() time.sleep(3)
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 test_partial(): c = wda.Client(__target) with c.session('com.apple.Preferences') as s: assert s(text="VP", partial=True).exists assert not s(text="VP").exists assert s(text="VPN").exists
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 pull_from_screen_ios(): global wda_client if wda_client is None: wda_client = wda.Client() wda_client.screenshot('image/backup.png')
def __init__(self, image_dir=settings.IMAGE_DIR): self.image_dir = image_dir self.client = wda.Client() self.session = self.client.session()
def main(): if 'Wechat_Jump' in Use_App: #################################################################### ######################## Wechat_Jump ############################### with open('config.json', 'r') as f: config = json.load(f) # Magic Number,不设置可能无法正常执行,请根据具体截图从上到下按需设置 under_game_score_y = config['under_game_score_y'] # 长按的时间系数,请自己根据实际情况调节 press_coefficient = config['press_coefficient'] # 二分之一的棋子底座高度,可能要调节 piece_base_height_1_2 = config['piece_base_height_1_2'] # 棋子的宽度,比截图中量到的稍微大一点比较安全,可能要调节 piece_body_width = config['piece_body_width'] time_coefficient = config['press_coefficient'] # 模拟按压的起始点坐标,需要自动重复游戏请设置成“再来一局”的坐标 swipe = config.get('swipe', { "x1": 320, "y1": 410, "x2": 320, "y2": 410 }) VERSION = "1.1.4" screenshot_backup_dir = 'screenshot_backups/' if not os.path.isdir(screenshot_backup_dir): os.mkdir(screenshot_backup_dir) while True: pull_screenshot() im = Image.open("./1.png") # 获取棋子和 board 的位置 piece_x, piece_y, board_x, board_y = find_piece_and_board(im) ts = int(time.time()) print(ts, piece_x, piece_y, board_x, board_y) if piece_x == 0: return set_button_position(im) distance = math.sqrt((board_x - piece_x)**2 + (board_y - piece_y)**2) jump(distance) save_debug_creenshot(ts, im, piece_x, piece_y, board_x, board_y) backup_screenshot(ts) # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban time.sleep(random.uniform(1, 1.1)) elif 'DouYin' in Use_App: ##################################################################### ########################### DouYin ################################## # 申请地址 http://ai.qq.com AppID = '1106858595' AppKey = 'bNUNgOpY6AeeJjFu' FACE_PATH = 'face/' Max_Try = 10 Girls = True Follow_Her = False Like_Her = True # 审美标准 BEAUTY_THRESHOLD = 80 Likes_max = 1 Save_Origin = True Save_Whole = True Save_Face = True for i in range(Max_Try): c = wda.Client( url='http://18.189.58.186:8100' ) # Please replace this by your own url from WebDriverAgent output. s = c.session() # s.swipe_up_pro() time.sleep(3) pull_screenshot(Use_App=Use_App, FACE_PATH=FACE_PATH) if Save_Origin: im = Image.open(FACE_PATH + 'autojump.png') im.save(FACE_PATH + 'autojump_%s.png' % (i)) try: resize_image(FACE_PATH + 'autojump.png', FACE_PATH + 'optimized.png', 1024 * 1024) with open(FACE_PATH + 'optimized.png', 'rb') as bin_data: image_data = bin_data.read() except: with open(FACE_PATH + 'autojump.png', 'rb') as bin_data: image_data = bin_data.read() ai_obj = apiutil.AiPlat(AppID, AppKey) rsp = ai_obj.face_detectface(image_data, 0) if rsp['ret'] == 0: beauty = 0 for face in rsp['data']['face_list']: print(face) face_area = (face['x'], face['y'], face['x'] + face['width'], face['y'] + face['height']) print(face_area) img = Image.open(FACE_PATH + "optimized.png") if Save_Whole: img.save(FACE_PATH + face['face_id'] + '_Whole.png') if Save_Face: cropped_img = img.crop(face_area).convert('RGB') cropped_img.save(FACE_PATH + face['face_id'] + '.png') # 性别判断 if Girls: if face['beauty'] > beauty and face['gender'] < 50: beauty = face['beauty'] else: if face['beauty'] > beauty and face['gender'] > 50: beauty = face['beauty'] # 是个美人儿~关注点赞走一波 if beauty > BEAUTY_THRESHOLD: print('发现漂亮妹子!!!') print('颜值: %s' % beauty) if Like_Her: for i in range( int((beauty - BEAUTY_THRESHOLD) / ((100 - BEAUTY_THRESHOLD) / Likes_max) + 1)): s.double_tap(x=w / 2, y=h / 2) print('Heart!') # time.sleep(0.11) if Follow_Her: s.tap(x=Follow_Sign_x, y=Follow_Sign_y) print('Follow!') # time.sleep(0.2) time.sleep(3) else: print('颜值: %s' % beauty) try: s.swipe_up_pro() except: time.sleep(10) c = wda.Client(url='http://18.189.58.186:8100') s = c.session() try: s.swipe_up_pro() except: pass time.sleep(1)
# Magic Number,不设置可能无法正常执行,请根据具体截图从上到下按需设置 under_game_score_y = config['under_game_score_y'] # 长按的时间系数,请自己根据实际情况调节 press_coefficient = config['press_coefficient'] # 二分之一的棋子底座高度,可能要调节 piece_base_height_1_2 = config['piece_base_height_1_2'] # 棋子的宽度,比截图中量到的稍微大一点比较安全,可能要调节 piece_body_width = config['piece_body_width'] time_coefficient = config['press_coefficient'] # 模拟按压的起始点坐标,需要自动重复游戏请设置成“再来一局”的坐标 swipe = config.get('swipe', {"x1": 320, "y1": 410, "x2": 320, "y2": 410}) delay_time = [1.00, 1.40] c = wda.Client('http://192.168.0.15:8100/') s = c.session() screenshot_backup_dir = 'screenshot_backups/' if not os.path.isdir(screenshot_backup_dir): os.mkdir(screenshot_backup_dir) def pull_screenshot(): c.screenshot('1.png') def game_end(im): im_pixel = im.load() # 以 50px 步长,尝试探测 scan_start_y
def __init__(self, device_url): import wda c = wda.Client(device_url) self._client = c self.__scale = c.session().scale
#!/usr/bin/python # -*- coding: UTF-8 -*- import Screencap import Constant import wda driver = wda.Client('http://192.168.100.25:8100') s = driver.session() def moveup(): print 1 def movedown(): print 2 def moveleft(): print 3 def moveright(): print 4 if __name__ == '__main__': s.screenshot().save(Constant.my_file)
pg = "" vl = "" for name, value in options: if name in ("-h", "--help"): usage() elif name in "-p": pg = value elif name in "-v": vl = value else: temp[name] = value print(temp) bundleid = pg gesture_num = int(vl) #与手机上的WebDriveAgent客户端链接 driver = wda.Client('http://localhost:8100') # 启动应用,建立会话 session = driver.session(bundleid) # 取得屏幕大小 height = session.window_size().height width = session.window_size().width print('宽和高:%s %s' % (width, height)) def up(): session.swipe(200, 600, 200, 300, 0.5) def down(): session.swipe(100, 300, 100, 600, 0.5)
# coding:utf-8 """ @Author: guozhiwen @Date: 2020/6/19 12:11 下午 @Description: """ import wda from core.ATXServer2 import ATXServer2 from core.utils.Loader import ReadConfig wdaUrl = None ios_devices = ATXServer2(ReadConfig().get_server_url()).present_ios_devices() if ios_devices: wdaUrl = ios_devices[0]['source']['wdaUrl'] c = wda.Client(wdaUrl) print(c.status()) print(c.healthcheck()) with c.session('com.genshuixue.student') as d: d(label=u"我的课程").click() d(label=u"返回").click()
import wda import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation from PIL import Image import random # 截图距离 * time_coefficient = 按键时长 # time_coefficient: # iphonex: 0.00125 # iphone6: 0.00196 # iphone6s plus: 0.00120 time_coefficient = 0.00196 c = wda.Client() s = c.session() def pull_screenshot(): c.screenshot('autojump.png') def jump(distance): press_time = distance * time_coefficient * random.uniform(0.98, 1.02) press_time = press_time print('press_time = ',press_time) s.tap_hold(200 * random.uniform(0.98, 1.02), 200 * random.uniform(0.98, 1.02), press_time) fig = plt.figure()
c = wda.Client(__target) with c.session('com.apple.Preferences') as s: # start_time = time.time() assert s.alert.wait(20) # print time.time() - start_time if __name__ == '__main__': # test_status() # test_set_text() # test_scroll() # # test_session() # test_partial() # test_alert_wait() c = wda.Client("http://localhost:8100") s = c.session() print ">>1<<" # els = c(text = u"同意") # print ">>2<<" # print els.displayed # print c(className = "Button", text = u"登录").displayed # for i in els.elements: # print i.keys() # print c.source().encode('utf-8') # print s(className = "Cell")[2].bounds # print s.alert.text # print s.alert.buttons() # for t in s(text = u"接单"): # print t.exists