ai 开始测试
This commit is contained in:
@@ -200,7 +200,7 @@ class AiUtils(object):
|
||||
homeButton = session.xpath("//*[@label='首页']")
|
||||
try:
|
||||
if homeButton.label == "首页":
|
||||
print("找到了")
|
||||
print("1.找到了")
|
||||
return homeButton
|
||||
else:
|
||||
print("没找到")
|
||||
@@ -243,7 +243,7 @@ class AiUtils(object):
|
||||
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("找到了")
|
||||
print("2.找到了")
|
||||
return followButton
|
||||
else:
|
||||
print("没找到")
|
||||
@@ -254,7 +254,7 @@ class AiUtils(object):
|
||||
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("找到了")
|
||||
print("3.找到了")
|
||||
return msgButton
|
||||
else:
|
||||
print("没找到")
|
||||
@@ -294,6 +294,16 @@ class AiUtils(object):
|
||||
root = etree.fromstring(xml.encode("utf-8"))
|
||||
items = []
|
||||
|
||||
# 判断是否是聊天页面
|
||||
is_chat_page = False
|
||||
if root.xpath('//XCUIElementTypeStaticText[contains(@traits, "Header")]'):
|
||||
is_chat_page = True
|
||||
elif root.xpath('//XCUIElementTypeCell//XCUIElementTypeOther[@name or @label]'):
|
||||
is_chat_page = True
|
||||
|
||||
if not is_chat_page:
|
||||
raise Exception("请先进入聊天页面")
|
||||
|
||||
# 屏幕宽度
|
||||
app = root.xpath('/XCUIElementTypeApplication')
|
||||
screen_w = cls.parse_float(app[0], 'width', 414.0) if app else 414.0
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import re
|
||||
|
||||
import tidevice
|
||||
from wda import Client
|
||||
from Utils.AiUtils import AiUtils
|
||||
from Utils.LogManager import LogManager
|
||||
|
||||
|
||||
# 页面控制工具类
|
||||
class ControlUtils(object):
|
||||
|
||||
@@ -59,8 +62,10 @@ class ControlUtils(object):
|
||||
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]")
|
||||
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:
|
||||
@@ -73,7 +78,7 @@ class ControlUtils(object):
|
||||
@classmethod
|
||||
def clickLike(cls, session: Client, udid):
|
||||
scale = session.scale
|
||||
x, y = AiUtils.findImageInScreen("add",udid)
|
||||
x, y = AiUtils.findImageInScreen("add", udid)
|
||||
print(x, y)
|
||||
if x > -1:
|
||||
print("点赞了")
|
||||
@@ -108,13 +113,29 @@ class ControlUtils(object):
|
||||
# 获取主播详情页的第一个视频
|
||||
@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 = 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]')
|
||||
|
||||
videoCell = session.xpath(
|
||||
'(//XCUIElementTypeCollectionView//XCUIElementTypeCell[.//XCUIElementTypeImage[@name="profile_video"]])[1]').get(
|
||||
timeout=5)
|
||||
|
||||
tab = session.xpath('//XCUIElementTypeButton[@name="TTKProfileTabVideoButton_0"]').get(timeout=2)
|
||||
# 某些版本 tab.value 可能就是数量;或者 tab.label 类似 “作品 7”
|
||||
m = re.search(r"\d+", tab.label)
|
||||
|
||||
num = 0
|
||||
|
||||
if m:
|
||||
# 判断当前的作品的数量
|
||||
num = int(m.group())
|
||||
print("作品数量为:", num)
|
||||
|
||||
if videoCell is not None:
|
||||
videoCell.click()
|
||||
# 点击视频
|
||||
return True
|
||||
print("找到主页的第一个视频")
|
||||
return True, num
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
print("没有找到主页的第一个视频")
|
||||
return False, num
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import requests
|
||||
from Entity.Variables import prologueList
|
||||
from Entity.Variables import prologueList
|
||||
|
||||
BaseUrl = "https://crawlclient.api.yolozs.com/api/common/"
|
||||
# BaseUrl = "http://192.168.1.174:8101/api/common/"
|
||||
@@ -17,9 +17,12 @@ class Requester():
|
||||
url = BaseUrl + cls.prologue
|
||||
result = requests.get(headers=headers, url=url)
|
||||
json = result.json()
|
||||
print("json",json
|
||||
)
|
||||
data = json.get("data")
|
||||
print("返回的数据",data)
|
||||
for i in data:
|
||||
prologueList.append(i)
|
||||
prologueList.append("hello")
|
||||
|
||||
|
||||
# 翻译
|
||||
|
||||
Reference in New Issue
Block a user