临时提交
This commit is contained in:
@@ -6,6 +6,7 @@ import numpy as np
|
||||
import wda
|
||||
from Utils.LogManager import LogManager
|
||||
import xml.etree.ElementTree as ET
|
||||
from wda import Client
|
||||
|
||||
# 工具类
|
||||
class AiUtils(object):
|
||||
@@ -236,10 +237,46 @@ class AiUtils(object):
|
||||
and (e.get('visible') in (None, 'true'))
|
||||
)
|
||||
|
||||
# 获取关注按钮
|
||||
@classmethod
|
||||
def getFollowButton(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("找到了")
|
||||
return followButton
|
||||
else:
|
||||
print("没找到")
|
||||
return None
|
||||
|
||||
# 查找发消息按钮
|
||||
@classmethod
|
||||
def getSendMesageButton(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("找到了")
|
||||
return msgButton
|
||||
else:
|
||||
print("没找到")
|
||||
return None
|
||||
|
||||
# 获取当前屏幕上的节点
|
||||
@classmethod
|
||||
def getCurrentScreenSource(cls):
|
||||
client = wda.USBClient("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
|
||||
print(client.source())
|
||||
|
||||
# AiUtils.getCurrentScreenSource()
|
||||
|
||||
# 查找app主页上的收件箱按钮
|
||||
@classmethod
|
||||
def getMsgBoxButton(cls, session: Client):
|
||||
box = session.xpath("//XCUIElementTypeButton[name='a11y_vo_inbox']")
|
||||
if box.exists:
|
||||
return box
|
||||
else:
|
||||
return None
|
||||
|
||||
# 获取收件箱中的未读消息数
|
||||
@classmethod
|
||||
def getUnReadMsgCount(cls, session: Client):
|
||||
btn = cls.getMsgBoxButton(session)
|
||||
return cls.findNumber(btn.label)
|
||||
@@ -53,15 +53,19 @@ class ControlUtils(object):
|
||||
@classmethod
|
||||
def clickBack(cls, session: Client):
|
||||
try:
|
||||
x, y = AiUtils.findImageInScreen("back")
|
||||
if x > 0:
|
||||
r = session.swipe_right()
|
||||
if r.status == 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
back = session.xpath("//*[@label='返回']")
|
||||
if back.exists:
|
||||
back.click()
|
||||
return True
|
||||
elif session.xpath("//*[@name='nav_bar_start_back']").exists:
|
||||
back = session.xpath("//*[@name='nav_bar_start_back']")
|
||||
back.click()
|
||||
return True
|
||||
elif session.xpath("//Window[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]").exists:
|
||||
back = session.xpath("//Window[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]")
|
||||
back.click()
|
||||
return True
|
||||
else:
|
||||
print("本页面无法返回")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(e)
|
||||
@@ -80,23 +84,6 @@ class ControlUtils(object):
|
||||
else:
|
||||
print("没有找到目标")
|
||||
return False
|
||||
# 点击评论
|
||||
# @classmethod
|
||||
# def clickComment(cls, session: Client):
|
||||
# scale = session.scale
|
||||
# x, y = AiUtils.findImageInScreen("add")
|
||||
# print(x,y)
|
||||
# if x > -1:
|
||||
# print("找到目标了")
|
||||
# r = session.click(x // scale, y // scale + 120)
|
||||
# if r.status == 0:
|
||||
# return True
|
||||
# else:
|
||||
# return False
|
||||
# else:
|
||||
# print("没有找到目标")
|
||||
# return False
|
||||
|
||||
|
||||
# 点击搜索
|
||||
@classmethod
|
||||
@@ -110,6 +97,16 @@ class ControlUtils(object):
|
||||
print(e)
|
||||
return False
|
||||
|
||||
# 点击收件箱按钮
|
||||
@classmethod
|
||||
def clickMsgBox(cls, session: Client):
|
||||
box = session.xpath("//XCUIElementTypeButton[name='a11y_vo_inbox']")
|
||||
if box.exists:
|
||||
box.click()
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# 获取主播详情页的第一个视频
|
||||
@classmethod
|
||||
def clickFirstVideoFromDetailPage(cls, session: Client):
|
||||
@@ -121,28 +118,5 @@ class ControlUtils(object):
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user