微信运动圈自动点赞(自动跳过自己)

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
原文地址:https://www.cnblogs.com/futrueface/p/15043255.html