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

@@ -5,6 +5,7 @@ import cv2
import numpy as np
import wda
from Utils.LogManager import LogManager
import xml.etree.ElementTree as ET
# 工具类
class AiUtils(object):
@@ -209,10 +210,10 @@ class AiUtils(object):
# 查找关闭按钮
@classmethod
def findCloseButton(cls,udid="eca000fcb6f55d7ed9b4c524055214c26a7de7aa"):
def findLiveCloseButton(cls,udid="eca000fcb6f55d7ed9b4c524055214c26a7de7aa"):
client = wda.USBClient(udid)
session = client.session()
session.appium_settings({"snapshotMaxDepth": 0})
session.appium_settings({"snapshotMaxDepth": 10})
r = session.xpath("//XCUIElementTypeButton[@name='关闭屏幕']")
try:
if r.label == "关闭屏幕":
@@ -223,4 +224,22 @@ class AiUtils(object):
print(e)
return None
# AiUtils.screenshot()
# 获取直播间窗口数量
@classmethod
def count_add_by_xml(cls, session):
xml = session.source()
root = ET.fromstring(xml)
return sum(
1 for e in root.iter()
if e.get('type') in ('XCUIElementTypeButton', 'XCUIElementTypeImage')
and (e.get('name') == '添加' or e.get('label') == '添加')
and (e.get('visible') in (None, 'true'))
)
# 获取当前屏幕上的节点
@classmethod
def getCurrentScreenSource(cls):
client = wda.USBClient("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
print(client.source())
# AiUtils.getCurrentScreenSource()

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

7
Utils/Requester.py Normal file
View File

@@ -0,0 +1,7 @@
from Entity.Variables import accountToken
class Requester():
@classmethod
def printToken(cls):
print(accountToken)