11号晚临时提交

This commit is contained in:
zw
2025-08-11 22:06:48 +08:00
parent e009577cc9
commit 747126f1f8
8 changed files with 283 additions and 71 deletions

View File

@@ -52,34 +52,34 @@ class ControlUtils(object):
# 返回
@classmethod
def clickBack(cls, session: Client):
x, y = AiUtils.findImageInScreen("back")
if x > 0:
r = session.swipe_right()
if r.status == 0:
return True
try:
x, y = AiUtils.findImageInScreen("back")
if x > 0:
r = session.swipe_right()
if r.status == 0:
return True
else:
return False
else:
print("本页面无法返回")
return False
else:
print("本页面无法返回")
except Exception as e:
print(e)
return False
# 点赞
@classmethod
def clickLike(cls, session: Client, udid):
scale = session.scale
x, y = AiUtils.findImageInScreen(udid,"add")
print(x,y)
x, y = AiUtils.findImageInScreen("add",udid)
print(x, y)
if x > -1:
print("找到目标")
r = session.click(x // scale, y // scale + 50)
if r.status == 0:
return True
else:
return False
print("点赞")
session.click(x // scale, y // scale + 50)
return True
else:
print("没有找到目标")
return False
# 点击评论
# @classmethod
# def clickComment(cls, session: Client):
@@ -103,11 +103,46 @@ class ControlUtils(object):
def clickSearch(cls, session: Client):
obj = session.xpath("//*[@name='搜索']")
try:
if obj.label == "搜索":
return obj
else:
return None
if obj.exists:
obj.click()
return True
except Exception as e:
print(e)
return None
return False
# 获取主播详情页的第一个视频
@classmethod
def clickFirstVideoFromDetailPage(cls, session: Client):
videoCell = session.xpath('//Window/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[2]/Other[1]/ScrollView[1]/Other[1]/CollectionView[1]/Cell[2]')
if videoCell.exists:
videoCell.click()
# 点击视频
return True
else:
return False
# 获取关注按钮
@classmethod
def clickFollowButton(cls, session: Client):
followButton = session.xpath('//Window[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[2]/Other[2]/Other[1]/Other[1]/Other[3]/Other[1]/Other[1]/Button[1]')
if followButton.exists:
print("找到了")
followButton.click()
return True
else:
print("没找到")
return False
# 查找发消息按钮
@classmethod
def clickSendMesageButton(cls, session: Client):
msgButton = session.xpath("//Window[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[2]/Other[2]/Other[1]/Other[1]/Other[3]/Other[1]/Other[1]")
if msgButton.exists:
print("找到了")
print(msgButton.name)
msgButton.click()
return True
else:
print("没找到")
return False