futrueface

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
import uiautomator2 as u2

d = u2.connect('172.20.25.212:5555')
d.implicitly_wait(5)
rid = '//*[@resource-id="com.tencent.mm:id/c68"]'
LLayout = '/android.widget.LinearLayout'
RLayout = '/android.widget.RelativeLayout'
TView = '/android.widget.TextView'
VGroup = 'android.view.ViewGroup'
IView = '/android.widget.ImageView'
View = '/android.view.View'

rid_RLayout = rid + RLayout
LLayout1_RLayout2 = LLayout + "[1]" + RLayout + "[2]"
RLayout1_RLayout1 = LLayout + "[1]" + RLayout + "[1]" + View

i = 1
position = []
me_Name = d.xpath(
rid + RLayout + '[2]' + LLayout1_RLayout2 + RLayout1_RLayout1).get_text()
while True:
try:
ele_path = d.xpath(
rid_RLayout + "[" + str(i) + "]" + LLayout1_RLayout2 + RLayout + "[2]" + RLayout + "[1]" + IView + "[1]")
ele_name = d.xpath(rid_RLayout + "[" + str(i) + "]" + LLayout1_RLayout2 + RLayout1_RLayout1).get_text()
if ele_name == me_Name:
continue
x, y = ele_path.center()
if i == 1:
position.append([x, y])
position.append([x, y])
else:
position[1] = [x, y]
if ele_path.exists:
ele_path.click()
print(ele_name + '微信运动已点赞')
except Exception as e:
d.drag(position[1][0], position[1][1], position[0][0], position[0][1])
i = 0
finally:
i += 1
posted on 2021-07-22 11:21  futrueface  阅读(408)  评论(0编辑  收藏  举报